English 中文(简体)
UI Barbutton 项目不是工具的正确方面?
原标题:UIBarbuttonItem is not in right side of tool bar?
  • 时间:2009-10-10 07:31:08
  •  标签:

i 在我看来,控制人员的确装满了同样的负荷。 项目不适宜工具条。 它左边。 任何帮助? 如何赋予工具禁运所有权?

UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlackTranslucent;

// create a bordered style button with custom title
UIBarButtonItem *playItem = [[[UIBarButtonItem alloc] initWithTitle:@"Play" 
            style:UIBarButtonItemStyleBordered  
            target:self
            action:@selector(flipToSchedules:)] autorelease];
self.navigationItem.rightBarButtonItem = playItem;
NSArray *items = [NSArray arrayWithObjects: playItem,  nil];
toolbar.items = items;

// size up the toolbar and set its frame
// please not that it will work only for views without Navigation toolbars. 
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGRect mainViewBounds = self.view.bounds;

[toolbar setFrame:CGRectMake(0, 20, 
             CGRectGetWidth(mainViewBounds), toolbarHeight)];
[self.view addSubview:toolbar];
最佳回答

将<条码>分光/条码>作为<条码>上载:right BarButtonItem本身,navigationItem是不明智的,因为这将把ton子确定为上列的航条,你希望将其放在工具栏(底)上。

为了解决这一问题,你不得不以灵活的方式创建另一个纽州,并补充说,作为工具路障的第一个项目:

UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
toolbar.items = [NSArray arrayWithObjects:flexible, playItem, nil];
[flexible release];
问题回答

暂无回答




相关问题
热门标签