popoverviewController 在 iPhone 上崩溃,在 iPad 上运行
这里有一个菜鸟问题:
任何想法为什么这段代码:
UIViewController* popoverviewController = [[UIViewController alloc]init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[webViewnetwork loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"webView" ofType:@"html"]isDirectory:NO]]];
[popoverView addSubview:webViewnetwork];
popoverviewController.view = popoverView;
popoverviewController.contentSizeForViewInPopover = CGSizeMake (100, 100);
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverviewController];
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
在 iPad 上运行良好,但在 iPhone 上崩溃? 我正在尝试做与 iPad 版本相同的事情,即添加一个带有 html 格式文本的子视图。它在第 7 行(initWithContentViewController)崩溃(程序收到信号:SIGABRT)
谢谢!
a noob question here:
any ideas why this code:
UIViewController* popoverviewController = [[UIViewController alloc]init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[webViewnetwork loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"webView" ofType:@"html"]isDirectory:NO]]];
[popoverView addSubview:webViewnetwork];
popoverviewController.view = popoverView;
popoverviewController.contentSizeForViewInPopover = CGSizeMake (100, 100);
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverviewController];
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
would work fine on iPad, but crash on iPhone ?
I'm trying to do the same thing as in my iPad version, which is adding a subview with an html formatted text. It crashes (program received signal: SIGABRT) on the 7th line (initWithContentViewController)
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为
UIPopoverController
仅在 iPad 上可用。Because
UIPopoverController
is only available on the iPad.您不能将 UIPopoverController 与 iPhone 一起使用。您将需要检测您正在使用哪种设备习惯用法并在运行时呈现适当的 viewController 类型。
此处项目提供了一些示例。其基本要点如下:
祝你好运。
You cannot use a UIPopoverController with iPhone. U will need to detect which device idiom u are using and present the appropriate viewController type at runtime.
The project here provides some examples. The basic gist of it is the following:
Good Luck.