UISegmentedControl``崩溃的Xcode
问题描述:
我想提上Navigation Item
UISegmentedControl
但它崩溃我的Xcode ..我只是简单地添加在界面生成器文件中的UISegmentedControl
(IB)文件,然后在viewDisAppear
UISegmentedControl``崩溃的Xcode
.H
IBOutlet UISegmentedControl *segmentedControl;
.M
self.navigationItem.titleView=segmentedControl;
这只是我崩溃的xcode与错误
2013-03-12 17:38:56.343 Magazine[4728:1dc03] *** Assertion failure in -[UINavigationBar layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
2013-03-12 17:38:56.344 Magazine[4728:1dc03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UINavigationBar's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
(0x2854012 0x1ee9e7e 0x2853e78 0x197ff35 0xe819ef 0x1efd6b0 0x7d1fc0 0x7c633c 0x7c6150 0x7440bc 0x745227 0x7458e2 0x281cafe 0x281ca3d 0x27fa7c2 0x27f9f44 0x27f9e1b 0x2d1c7e3 0x2d1c668 0xe3165c 0x2de5 0x2ce5)
的libC++ abi.dylib:终止叫做抛出异常
为什么这个错误是未来
答
UISegmentedControl * seg1 = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:@"von mir", @"alle", nil]];
[seg1 setSegmentedControlStyle:UISegmentedControlStyleBar];
self.navigationItem.titleView = seg1;
你在哪里把分割控制在界面生成器?难道你不能直接在nib文件中使分割控件成为标题视图吗? – architectpianist 2013-03-12 12:19:52
通常在视图中...但如何使直接在笔尖文件中的标题视图的分段控制 – Christien 2013-03-12 12:22:13
为什么你把段放在XIB中,然后在代码中给出?相反,你可以分配init的segmentedControl通过代码,然后尝试.. – 2013-03-12 12:22:43