Objective c 无法使用目标c更改uitoolbar的高度
我已成功添加具有以下代码的UIToolBar:Objective c 无法使用目标c更改uitoolbar的高度,objective-c,uitoolbar,Objective C,Uitoolbar,我已成功添加具有以下代码的UIToolBar: -(void) setUpBottom{ UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; UIBarButtonItem *feature = [[UIBarButtonItem alloc]init
-(void) setUpBottom{
UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *feature = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"features.png"] style:UIBarButtonItemStylePlain target:self action:@selector(selectFeature:)];
UIBarButtonItem *fav = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"favorite-outline.png"] style:UIBarButtonItemStylePlain target:self action:@selector(selectFavorite:)];
//following line was intended to change the height of the tool bar, but it doesn't work.
[[self navigationController].toolbar setFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 55, [[UIScreen mainScreen] bounds].size.width, 55)];
self.toolbarItems = [NSArray arrayWithObjects:flexible,feature, flexible,fav,flexible,nil];
[[self navigationController] setToolbarHidden:NO];
}
令我惊奇的是:
当我将toolBarItems分配给[self-navigationController].toolBarItems时,该项目将不会显示
我找不到任何API来修改工具栏的高度,因此我必须修改[self-navigationController]上不起作用的API
所以我的问题是如何修改boolbar的高度,以及self.toolbarItems和[self-navigationController].toolbarItems之间的关系?谢谢。UINavigationController的ToolbarItems属性对其自己的工具栏没有影响
NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationController : UIViewController
您应该注意,它是从UIViewController继承的,仅当您将该导航控制器放在另一个导航控制器中时才有效
要增加的高度,我认为您不能将其子类化并更改intrinsicContentSize或sizeThatFits
您可以根据以下内容创建UIView和ad作为子视图:
可以使用UIViewController的方法指定一组自定义工具栏项
但是我不确定您是否可以更改内置工具栏的高度您的意思是我应该创建一个UIView并将该子视图放在底部作为选项卡,而不是使用工具栏,对吗?是的,您可以制定另一个解决方案