0

嘿,我是 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];
}

安慰:

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 时,我仍然会卡住。

4

1 回答 1

0

您可能无法使用init. 您必须在初始化时指定内容视图控制器-initWithContentViewController:。您触发的导致崩溃的断言以及文档UIPopoverController将告诉您这一点。

于 2012-07-03T05:06:21.380 回答