如何将UIBarButtonItem放置在UIToolbar的右侧? [英] How to place UIBarButtonItem on the right side of a UIToolbar?

查看:280
本文介绍了如何将UIBarButtonItem放置在UIToolbar的右侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一个视图,其中有一个在Interface Builder中以模态方式显示的工具栏。我有一个UIBarButtonItem在左手边,我想显示在工具栏的右侧。我如何在IB或通过代码?

I have designed a view with a toolbar that appears modally in Interface Builder. I have a UIBarButtonItem that is on the left hand side, which I would like to appear on the right hand side of the toolbar. How can I do this in IB, or via code?

推荐答案

如果有人遇到这篇文章:

Here's how to do it in code if anyone comes across this post:

UIBarButtonItem *leftButton = [[[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStyleBordered target:self action:@selector(btnItem1Pressed:)] autorelease];

UIBarButtonItem *flex = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil] autorelease];

UIBarButtonItem *rightButton = [[[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStyleBordered target:self action:@selector(btnItem2Pressed:)] autorelease];


self.toolbarItems = [NSArray arrayWithObjects: leftButton, flex, rightButton, nil];

这篇关于如何将UIBarButtonItem放置在UIToolbar的右侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆