0

我正在尝试穿上它UISegmentedControlNavigation Item 但它使我的 xcode 崩溃.. 我只是UISegmentedControl在 Interface Builder 文件(IB)文件中添加了,然后在viewDisAppear

。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:终止调用抛出异常

为什么会出现这个错误

4

1 回答 1

2
UISegmentedControl * seg1 = [[UISegmentedControl alloc]
    initWithItems:[NSArray arrayWithObjects:@"von mir", @"alle", nil]];
[seg1 setSegmentedControlStyle:UISegmentedControlStyleBar];
self.navigationItem.titleView = seg1;
于 2013-03-12T12:20:32.187 回答