我前幾天學習了應用程序開發,並面臨第一個問題。基本上我想實現的是隱藏和禁用後退按鈕,當沒有UIWebView的歷史。這裏是我的代碼:超初學者。隱藏UIBarButton問題
-(IBAction)backButtonPressed:(id)sender {
[webView goBack];
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [[NSURL alloc] initWithString:@"http://nearom.com"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[self.webView loadRequest:request];
}
- (void) backButton{
if(webView.canGoBack == YES)
{
back.enabled = YES;
back.width = 0;
back.title = @"back";
}
else {
back.enabled = NO;
back.width = 0.01;
back.title = nil;
}
}
- (void)webViewDidFinishLoad:(UIWebView *)thisWebView{
[self backButton];
}
但backButton方法不起作用。有人可以解釋我做錯了什麼嗎?