【问题标题】:popover init error in 5.15.1 中的弹出框初始化错误
【发布时间】:2012-04-03 06:06:22
【问题描述】:

我得到了使用 SplitViewController 和弹出框的应用程序,标准的东西。它适用于从 sdk 3.0 开始的 10 个版本。它仍然可以在 Snow Leopard、Xcode 4.2 和 sdk 5.0 的模拟器中编译并正常工作。但是,在 Lion、Xcode 4.3 和 sdk 5.1 上运行时会抛出错误:

-[_UISlidingPopoverLayoutInfo _popoverViewSizeForContentSize:arrowDirection:] 中的断言失败,/SourceCache/UIKit_Sim/UIKit-1914.84/_UIPopoverLayoutInfo.m:160

* 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“未知方向传递给 _popoverViewSizeForContentSize:arrowDirection:”

popover 仅作为类的一部分启动:

@interface NewsDetailViewController : UIViewController <UIActionSheetDelegate, UISplitViewControllerDelegate, UIWebViewDelegate>{

    RssFunAppDelegate * _appDelegate;
    UITextView * _titleTextView;
    UINavigationBar * _navigationBar;
    UIPopoverController * _popContr;    
    UIWebView * _webView;
    UIActivityIndicatorView * _activityIndicator;
}

【问题讨论】:

  • 您的头文件代码与错误无关,因此那段代码无关紧要。将代码发布到您调用弹出框的@implementation 中。
  • 是的,您需要在创建和使用弹出框的位置发布代码。

标签: iphone xcode uipopovercontroller


【解决方案1】:

您需要发布初始化UIPopoverController 的代码以获得任何真正的帮助。

不过,从阅读异常文本开始,我会先调查初始化程序,看看您是否将它设置为任何奇怪的东西。唯一支持的值是:

UIPopoverArrowDirectionUp
UIPopoverArrowDirectionDown
UIPopoverArrowDirectionLeft
UIPopoverArrowDirectionRight
UIPopoverArrowDirectionAny

或这些的按位组合,例如

UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight

【讨论】:

  • UIPopoverController 从未显式初始化。唯一使用的地方是 splitViewController 处理,但我怀疑它是否相关: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (interfaceOrientation == UIInterfaceOrientationPortrait) { [_popContr presentPopoverFromBarButtonItem:_navigationBar.topItem.leftBarButtonItem allowedArrowDirections:UIPopoverArrowDirectionAny animated:YES ]; } 返回是; }
  • - (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController )aViewController withBarButtonItem:(UIBarButtonItem)barButtonItem forPopoverController: (UIPopoverController*)pc { barButtonItem.title = NSLocalizedString(@"新闻项目",@"按钮标题"); [_navigationBar.topItem setLeftBarButtonItem:barButtonItem 动画:YES]; _popContr = 个人计算机; }
  • - (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { [_navigationBar.topItem setLeftBarButtonItem:nil animated:YES]; _popContr=零; }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-18
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多