UISegmentedControl``在导航项上崩溃Xcode

时间:2013-03-12 12:14:56

标签: iphone ios ipad uisegmentedcontrol uinavigationitem

我正在尝试将UISegmentedControl放在Navigation Item上,但它会导致我的xcode崩溃..我只是将UISegmentedControl添加到Interface Builder文件(IB)文件中,然后添加到{{ 1}}

·H

viewDisAppear

.m

 IBOutlet UISegmentedControl *segmentedControl;

这只是让我的xcode崩溃了

 self.navigationItem.titleView=segmentedControl;

libc ++ abi.dylib:终止调用抛出异常

为什么会出现此错误

1 个答案:

答案 0 :(得分:2)

UISegmentedControl * seg1 = [[UISegmentedControl alloc]
    initWithItems:[NSArray arrayWithObjects:@"von mir", @"alle", nil]];
[seg1 setSegmentedControlStyle:UISegmentedControlStyleBar];
self.navigationItem.titleView = seg1;