iOS alloc popover 控制器导致崩溃

发布于 2024-12-20 05:08:05 字数 3236 浏览 3 评论 0原文

您好,我正在尝试通过单击按钮来实现弹出窗口,这是我之前成功完成的,但由于某种原因我无法实现它。我现在使用的是 iOS 5。

到目前为止,我

-(void)changetablebuttonPressed:(id)sender{
UIButton *button = (UIButton*)sender;

changetableView = [[ChangeTableViewController alloc] initWithNibName:@"ChangeTableViewController" bundle:nil];
changetablePopover = [[UIPopoverController alloc] initWithContentViewController:changetableView];
[changetablePopover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:TRUE];     
}

在尝试 initWithContentViewController 甚至简单的 init 后,代码会导致 SIGABRT 错误。我已经检查过 changetableView 不为空,所以我被难住了!

ChangeTableViewController 中唯一的自定义代码位于 viewDidLoad 中,并且是 self.contentSizeForViewInPopover = CGSizeMake(320, 144);

如有任何猜测,我们将不胜感激。

编辑: 异常没有被打印到控制台(我不认为),这是启用了僵尸的整个输出:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 7596.
Catchpoint 2 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved

Catchpoint 2 (exception thrown).(gdb) bt
#0  0x03dc9a4f in __cxa_throw ()
#1  0x01745e15 in objc_exception_throw ()
#2  0x0155ca78 in +[NSException raise:format:arguments:] ()
#3  0x0155c9e9 in +[NSException raise:format:] ()
#4  0x001c7f0d in -[UIViewController _loadViewFromNibNamed:bundle:] ()
#5  0x001c83a9 in -[UIViewController loadView] ()
#6  0x001c85cb in -[UIViewController view] ()
#7  0x00596559 in -[UIPopoverController _transitionFromViewController:toViewController:animated:] ()
#8  0x00593b13 in -[UIPopoverController initWithContentViewController:] ()
#9  0x0000b7f7 in -[DetailViewController changetablebuttonPressed:] (self=0x6a510e0, _cmd=0x18af6, sender=0x6a696f0) at .../DetailViewController.m:385
#10 0x015b5ec9 in -[NSObject performSelector:withObject:withObject:] ()
#11 0x001055c2 in -[UIApplication sendAction:to:from:forEvent:] ()
#12 0x0010555a in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#13 0x001aab76 in -[UIControl sendAction:to:forEvent:] ()
#14 0x001ab03f in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#15 0x001aa2fe in -[UIControl touchesEnded:withEvent:] ()
#16 0x003c3a2a in _UIGestureRecognizerUpdate ()
#17 0x015889ce in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#18 0x0151f670 in __CFRunLoopDoObservers ()
#19 0x014eb4f6 in __CFRunLoopRun ()
#20 0x014eadb4 in CFRunLoopRunSpecific ()
#21 0x014eaccb in CFRunLoopRunInMode ()
#22 0x0149d879 in GSEventRunModal ()
#23 0x0149d93e in GSEventRun ()
#24 0x00102a9b in UIApplicationMain ()
#25 0x00002b42 in main (argc=1, argv=0xbfffed78) at .../main.m:16
#26 0x00002ab5 in start ()
Current language:  auto; currently objective-c
(gdb) 

Hi I'm trying to make a popover happen on the click of a button, something I've done successfully before, but for some reason I can't make it happen. I'm using iOS 5 now.

So far I have

-(void)changetablebuttonPressed:(id)sender{
UIButton *button = (UIButton*)sender;

changetableView = [[ChangeTableViewController alloc] initWithNibName:@"ChangeTableViewController" bundle:nil];
changetablePopover = [[UIPopoverController alloc] initWithContentViewController:changetableView];
[changetablePopover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:TRUE];     
}

The code causes a SIGABRT error after trying to initWithContentViewController or even a straightforward init. I've checked that changetableView is not null and so I'm stumped!

The only custom code in the ChangeTableViewController is in viewDidLoad and is self.contentSizeForViewInPopover = CGSizeMake(320, 144);

Any guesses would be appreciated.

EDIT:
The exception isn't being printed to the console (I don't think), here is the entire output, with Zombies enabled:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 7596.
Catchpoint 2 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved

Catchpoint 2 (exception thrown).(gdb) bt
#0  0x03dc9a4f in __cxa_throw ()
#1  0x01745e15 in objc_exception_throw ()
#2  0x0155ca78 in +[NSException raise:format:arguments:] ()
#3  0x0155c9e9 in +[NSException raise:format:] ()
#4  0x001c7f0d in -[UIViewController _loadViewFromNibNamed:bundle:] ()
#5  0x001c83a9 in -[UIViewController loadView] ()
#6  0x001c85cb in -[UIViewController view] ()
#7  0x00596559 in -[UIPopoverController _transitionFromViewController:toViewController:animated:] ()
#8  0x00593b13 in -[UIPopoverController initWithContentViewController:] ()
#9  0x0000b7f7 in -[DetailViewController changetablebuttonPressed:] (self=0x6a510e0, _cmd=0x18af6, sender=0x6a696f0) at .../DetailViewController.m:385
#10 0x015b5ec9 in -[NSObject performSelector:withObject:withObject:] ()
#11 0x001055c2 in -[UIApplication sendAction:to:from:forEvent:] ()
#12 0x0010555a in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#13 0x001aab76 in -[UIControl sendAction:to:forEvent:] ()
#14 0x001ab03f in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#15 0x001aa2fe in -[UIControl touchesEnded:withEvent:] ()
#16 0x003c3a2a in _UIGestureRecognizerUpdate ()
#17 0x015889ce in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#18 0x0151f670 in __CFRunLoopDoObservers ()
#19 0x014eb4f6 in __CFRunLoopRun ()
#20 0x014eadb4 in CFRunLoopRunSpecific ()
#21 0x014eaccb in CFRunLoopRunInMode ()
#22 0x0149d879 in GSEventRunModal ()
#23 0x0149d93e in GSEventRun ()
#24 0x00102a9b in UIApplicationMain ()
#25 0x00002b42 in main (argc=1, argv=0xbfffed78) at .../main.m:16
#26 0x00002ab5 in start ()
Current language:  auto; currently objective-c
(gdb) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

数理化全能战士 2024-12-27 05:08:05

检查您的笔尖是否存在流氓 IBOutlet。当您将视图(在 Interface Builder 中)定义为一个类,然后将其更改为另一个类,但不清除旧连接时,有时会发生这种情况。 (我最初说过这只是删除 .h 中的出口,但意识到这是错误的情况,并回忆起正确的情况)。

您正在寻找右侧带有黄色三角形的出口,例如:

在此处输入图像描述

它发生在加载过程中视图的一部分,即笔尖加载器尝试将对象与其出口配对时。

Check your nib for a rogue IBOutlet. It sometimes happens when you defined a view (in Interface Builder) as one class, then later change it to another class, but don't clean up the old connections. (I had originally stated it was simply from deleting the outlet in your .h, but realized that was the wrong scenario, and recalled the correct one).

You are looking for an outlet with the yellow triangle to the right, like:

enter image description here

It is happening during the loading of the view, which is when the nib loader is trying to pair up objects with their outlets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文