1
我試圖通過javascipt的獲得加載的網頁的標題和地點,作爲一個UIActionSheet的標題像這樣:搶UIWebView的頁面標題爲NSString的
我有什麼目前我ViewController.m:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *webTitle = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}
- (IBAction)showActionSheet:(id)sender {
// webTitle.text receives errors
UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:webTitle delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share...", @"Bookmarks", @"Read Later", @"Add to Bookmarks", @"Settings", nil];
actionsheet.actionSheetStyle = UIBarStyleBlackTranslucent;
[actionsheet showInView:self.view];
NSLog(@"Action Menu opened");
}
編輯:我也收到這些警告。
EDIT2:評估通過JavaScript警告正常工作的代碼。
如果您嘗試在您的javascript字符串中提醒標題,會發生什麼? – 2013-03-16 19:43:00
提醒標題? – 2013-03-16 19:49:41
是的,所以不是評估JavaScript字符串'document.title',而是評估'alert(document.title)'。 – 2013-03-16 19:50:41