0
我有一個UITableViewController。我想在底部顯示一個UIToolbar,但我不知道如何做到這一點,因爲IB不允許我添加它。如何添加UIToolbar到我的UITableViewController?
我有一個UITableViewController。我想在底部顯示一個UIToolbar,但我不知道如何做到這一點,因爲IB不允許我添加它。如何添加UIToolbar到我的UITableViewController?
只是用它嘗試:
在.h文件中:
UIToolbar* toolbar;
在.m文件
UIBarButtonItem *actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(doAction)];
toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleDefault;
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGRect mainViewBounds = appDel.window.bounds;
[toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),
438,
CGRectGetWidth(mainViewBounds),
toolbarHeight)];
[[[UIApplication sharedApplication] keyWindow] addSubview:toolbar];
你試圖progammatically添加它作爲你的子視圖的UITableViewController? – Mat