Ios 以编程方式添加UIToolbar
我做错了什么?我只是看不到屏幕底部的工具栏,这是我的代码Ios 以编程方式添加UIToolbar,ios,ios4,Ios,Ios4,我做错了什么?我只是看不到屏幕底部的工具栏,这是我的代码 CGRect rect = self.view.frame; UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(rect.origin.x, rect.size.height-44,
CGRect rect = self.view.frame;
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(rect.origin.x,
rect.size.height-44,
rect.size.width,
44)];
self.bottomToolbar = toolBar;
[toolBar release];
[_bottomToolbar setBackgroundImage:nil
forToolbarPosition:UIToolbarPositionBottom
barMetrics:UIBarMetricsDefault];
[self.view addSubview:_bottomToolbar];
缺少一行,其大小为Fit或makeKeyAndVisible()
只需查看ViewControllerProgrammingGuide中的示例您需要将工具栏的
自动调整大小掩码
设置为“灵活上边距”值
此外,您的代码还处理
toolBar
变量、bottomToolbar
属性和\u bottomToolbar
ivar。使用属性或ivar。像你这样同时使用这两种语言是令人困惑的 您是否尝试过[self.parentViewController.view addSubview:_bottomtoolbar];?您是否在应用程序中使用NavigationController?还是Tabbar?autorisingMask=UIViewAutoresizingFlexibleTopMargin