他是xcode编程的新手。所以这个问题可能听起来很荒谬。我正在尝试UIWebview
中的各种功能。我成功添加了URL文本框并在Google文本框中搜索。现在,我试图允许用户添加书签。为此,我将URL保存在一个数组中。但是,当我单击书签栏按钮项时,我想要弹出UIPopover
视图。尝试初始化UIPopoverController
时,我一直收到此错误。
objPopOverController = [[UIPopoverController alloc]init ];
有关为何在此处抛出异常的任何帮助。
感谢。
编辑:
- (IBAction)addBookmark:(UIBarButtonItem *)sender {
BookmarkPopover *objBook = [[BookmarkPopover alloc]init];
objPopOverController = [[UIPopoverController alloc]init ];
objPopOverController.contentViewController = objBook;
objPopOverController.delegate = self;
objPopOverController.popoverContentSize = CGSizeMake(180, 120);
[objPopOverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
CONSOLE:
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 13287.
Pending breakpoint 1 - "objc_exception_throw" resolved
[Switching to process 13287 thread 0x2303]
[Switching to process 13287 thread 0x207]
sharedlibrary apply-load-rules all
Error in re-setting breakpoint 1:
Catchpoint 2 (throw)Error in re-setting breakpoint 1:
Error in re-setting breakpoint 1:
Current language: auto; currently objective-c
(gdb)
self ViewController * 0x6829f20
_cmd SEL 0x4437
sender UIBarButtonItem * 0x6a33020
objBook BookmarkPopover * 0x68528b0
Registers (null) (null)
Vector Registers (null) (null)
x87 Registers (null) (null)
编辑2:
我尝试用语法初始化UIView,然后添加它,但它仍然给我同样的错误。
-(IBAction) buttonAction:(id)sender {
//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)];
popoverView.backgroundColor = [UIColor whiteColor];
popoverContent.view = popoverView;
//resize the popover view shown
//in the current view to the view's size
popoverContent.contentSizeForViewInPopover = CGSizeMake(200, 300);
//create a popover controller
self.objPopOverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
//present the popover view non-modal with a
//refrence to the button pressed within the current view
[self.objPopOverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
//release the popover content
}
当我初始化我的PopOverController时,我仍然感到困惑。
答案 0 :(得分:0)
您可能无法使用init
初始化弹出框控制器。您必须使用-initWithContentViewController:
在初始化时指定内容视图控制器。您触发的导致崩溃的断言以及UIPopoverController
的文档都会告诉您这一点。