2010-03-12 50 views
1

是否可以平衡按钮的位置(Safari中的示例工具栏)?如何在工具栏中平衡UIBarButtonItem的位置

UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] 
             initWithBarButtonSystemItem:UIBarButtonSystemItemCompose 
             target:self action:@selector(support:)]; 

     UIBarButtonItem *next = [[UIBarButtonItem alloc] 
             initWithBarButtonSystemItem:UIBarButtonSystemItemPlay 
             target:self action:@selector(support:)]; 
     [self.navigationController.toolbar setItems:[NSArray arrayWithObjects:infoButton, next,nil] animated:YES]; 

alt text

回答

7

您需要两个按钮项目之间加入了一个灵活的空间项目。

更多详细内容可在Apple的UICatalog sample code中找到。例如:

// flex item used to separate the left groups items and right grouped items 
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                      target:nil 
                      action:nil]; 
+0

谢谢Shaggy Frog让我试试 – RAGOpoR 2010-03-12 07:08:11

+0

我可以问更多问题吗? 是否可以禁用self.navigationController.toolbar项目 谢谢 – RAGOpoR 2010-03-12 10:05:01

+0

您应该问一个单独的问题,并尽量使问题尽可能完整。 – 2010-03-12 18:23:43