[英]How can i add a next and previous button at the segmented Controller on a navigation bar in iphone application development?
我很麻烦....如何在分段栏中设置下一个和上一个按钮/箭头...如果有人需要我的问题的简要说明,请参阅此链接... 我如何添加下一个和上一个按钮在分段控制器上?
我已附上一张图片以了解问题所在...所以有人请帮助我....
注意:在我当前的项目中,有超过5个按钮可添加到分段栏上,因此当我按下一个/上一个箭头时,分段栏应从他的位置移开。如果您对我的问题不清楚,请参阅我的另一个链接...。
提前致谢
编辑:
UIBarButtonItem *previousBarButtonItem = [[UIBarButtonItem alloc] //init];
initWithTitle:@"<"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(previousBarButtonAction:)];
self.navigationItem.leftBarButtonItem = previousBarButtonItem;
[previousBarButtonItem release];
UIBarButtonItem *nextBarButtonItem = [[UIBarButtonItem alloc] //init];
initWithTitle:@">"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(nextBarButtonAction:)];
self.navigationItem.rightBarButtonItem = nextBarButtonItem;
[nextBarButtonItem release];
//This Portion For UIToolbar
topToolBar = [UIToolbar new];
topToolBar.barStyle = UIBarStyleDefault;
[topToolBar sizeToFit];
topToolBar.frame = CGRectMake(50, 410, 280, 50);
//Add buttons
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(pressButton1:)];
UIBarButtonItem *systemItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(pressButton2:)];
UIBarButtonItem *systemItem3 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCamera
target:self action:@selector(pressButton3:)];
//Use this to put space in between your toolbox buttons
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
//Add buttons to the array
NSArray *items = [NSArray arrayWithObjects: systemItem1, flexItem, systemItem2, flexItem, systemItem3, nil];
//release buttons
[systemItem1 release];
[systemItem2 release];
[systemItem3 release];
[flexItem release];
//add array of buttons to toolbar
[topToolBar setItems:items animated:NO];
self.navigationItem.titleView = topToolBar;
这是我当前的编码位置,现在我在uitoolbar中有4个按钮,但是只能看到3个按钮,所以当我按下一个或上一个按钮来查看uitoolbar框架之外的其他按钮时,我想移动此工具栏?
编辑:
我可以使用uiview动画滚动导航栏项目,但是现在我的问题是,当我按下next / prev按钮时,它根据uitoolbar坐标的更改从当前位置移动,并在pre / next子项目上移动不在uitoolbar项中的框架。 但是它应该在uiview中并且应该在uiview中更改坐标,而不是超出视图...现在告诉我该怎么办。
首先,在图中看到的NavigationBar实际上是UIToolBar
。 不幸的是,无法在UINavigationBar
上添加更多控件。 但是您可以使用UIToolBar
实现完全相同的UI,您可以在其中添加任何控件。
因此,要使用UIToolBar
而不是UINavigationBar
来实现此UIToolBar
。 还可以使用带有自定义标题的UIBarButtonItem
来实现“ 下一个”和“ 上一个”功能。
编辑
以下是一些链接,例如UIToolBar
但这一切都说明了使用代码。 而不是使用Interface Builder ,使用UIToolBar
变得太容易了(如果编码不是那么重要)。
我认为这有点过于复杂-您不能只将两个UIBarButtonItems的文本设置为“ <”和“>”吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.