I have the following code to create a UIWebView programmatically and create a UIButton on top of it to close it. The creation is fine, but the problem is that I cannot return to the created UIWebView to close it with a button!
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [self.view addSubview:webView]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Close" forState:UIControlStateNormal]; button.frame = CGRectMake(80, 210, 160, 40); [button addTarget:self action:@selector(close:) forControlEvents:UIControlEventTouchUpInside]; [webView addSubview:button]; - (IBAction)close:(id)sender { ???? }
Thanks for your help in advance :)
xcode uibutton uiwebview
Dezigny
source share