【发布时间】:2014-04-29 08:08:53
【问题描述】:
我正在尝试将工具栏添加到我的视图控制器。
我的视图控制器:
-(void)loadView
{
UIWebView *webView = [[UIWebView alloc]init];
webView.scalesPageToFit = YES;
self.view = webView;
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0,self.view.bounds.size.height-50, self.view.bounds.size.width, 50);
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithTitle:@"Send" style:UIBarButtonItemStyleDone target:self action:@selector(sendAction)];
UIBarButtonItem *button2=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleDone target:self action:@selector(cancelAction)];
[toolbar setItems:[[NSArray alloc] initWithObjects:button1, nil]];
[toolbar setItems:[[NSArray alloc] initWithObjects:button2, nil]];
[self.view addSubview:toolbar];
}
工具栏不会显示。
我应该避免:
self.view = webView;
只需设置 self.view 的框架,然后将 webView 添加为子视图?
【问题讨论】:
标签: ios iphone objective-c uiviewcontroller uiwebview