【发布时间】:2009-10-02 12:12:57
【问题描述】:
我是 iphone 编程新手,所以如果你能帮助我,我将不胜感激 - 我已经在网上找到了答案。
我现在的设置是这样的
MainWindow.xib 中的导航控制器 > MainWindow.xib 中导航控制器中的视图调用 RootViewController.xib > RootViewController.xib 包含单个 tableview。
然后我可以使用 RootViewController.m 中的以下代码加载到工具栏中
UIBarButtonItem *buttonOne = [[UIBarButtonItem alloc] initWithTitle:@"One"
style:UIBarButtonItemStyleBordered target:self action:@selector(buttonOnePushed)];
UIBarButtonItem *buttonTwo = [[UIBarButtonItem alloc] initWithTitle:@"Two"
style:UIBarButtonItemStyleBordered target:self action:@selector(buttonTwoPushed)];
NSArray *barArray = [NSArray arrayWithObjects: buttonOne, buttonTwo, nil];
[buttonOne release];
[buttonTwo release];
[self setToolbarItems:barArray animated:YES];
[self.navigationController setToolbarHidden:NO animated:YES];
此代码适用于按钮。但我无法终生了解如何添加分段控件而不是按钮。我尝试了一个包含两个分段控件的数组,但无法将数组添加到工具栏。
如果有人能告诉我一些代码,这些代码将以与添加按钮相同的方式添加分段控件,我将不胜感激。
谢谢,戴夫。
【问题讨论】:
标签: iphone uitableview navigation controller toolbar