iOS alloc弹出控制器导致崩溃

时间:2011-12-07 17:57:34

标签: ios uiviewcontroller initialization uipopovercontroller

嗨,我正试图通过点击按钮来实现弹出窗口,这是我以前成功完成的事情,但出于某种原因我无法实现。我现在正在使用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中唯一的自定义代码位于viewDidLoadself.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) 

1 个答案:

答案 0 :(得分:5)

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

您正在寻找右侧带黄色三角形的插座,例如:

enter image description here

在加载视图期间发生这种情况,即当nib加载器尝试将对象与其出口配对时。