Objective c 无法获取导航栏左侧的分段控件
我试图以编程方式将UISegementedControl添加到导航栏的左侧。我可以通过将控件设置到TimeVIEW显示在中间,如下所示。下面是我的代码Objective c 无法获取导航栏左侧的分段控件,objective-c,uisegmentedcontrol,Objective C,Uisegmentedcontrol,我试图以编程方式将UISegementedControl添加到导航栏的左侧。我可以通过将控件设置到TimeVIEW显示在中间,如下所示。下面是我的代码 NSArray *buttonNames = [NSArray arrayWithObjects:@"One", @"Two", nil]; UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] segmentedControl.segmentedControlSty
NSArray *buttonNames = [NSArray arrayWithObjects:@"One", @"Two", nil];
UISegmentedControl* segmentedControl = [[UISegmentedControl alloc]
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
// instead of the following I would like to move to left side of the nav bar
self.navigationItem.titleView = segmentedControl;
非常感谢您的帮助。您试过了吗
[[UIBarButtonItem alloc] initWithCustomView:...]
?
更确切地说,可能是这样的
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
self.navigationItem.leftBarButtonItem = item;
[item release];