我有一個問題,即將字符串傳遞給一個Web地址的函數,以便通過webview打開該特定方向。如何將網址字符串傳遞到函數
-(IBAction)toWeb:(NSString*)web_direction {
UIViewController *webViewController = [[[UIViewController alloc] init] autorelease];
UIWebView *uiWebView = [[[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,480)] autorelease];
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:web_direction]]];
[webViewController.view addSubview: uiWebView];
webViewController.title = @"web bar";
[self.navigationController pushViewController:webViewController animated:YES];
}
我想用調用通過MKannotation該函數:
NSString *direction = @"http://www.google.com";
[btnDetails addTarget:self action:@selector(toWeb:direction) forControlEvents:UIControlEventTouchUpInside];
但應用程序崩潰。任何想法呢?
通常當你調用一個IBAction的時候發送的是發送者,我不確定你在用那個字符串時想要做什麼。 –