我在我的文本字段中创建了一个按钮并调用我的bookMarks
方法。这适用于iphone。如果我在工具栏中创建一个按钮并调用此方法,仍然可以正常工作。它只是在我的文本字段中不起作用。有没有办法解决这个问题?谢谢..
[bookMarkButton addTarget:self action:@selector(bookMarks:) forControlEvents:UIControlEventTouchUpInside];
locationField.leftView = bookMarkButton;
书签法
- (void)bookMarks:(id)button {
if (self.bookmarkPopoverController.popoverVisible) {
[self.bookmarkPopoverController dismissPopoverAnimated:YES];
self.bookmarkPopoverController = nil;
} else {
ViewBookmarkViewController * viewBookmarkViewController = [[[ViewBookmarkViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
viewBookmarkViewController.delegate = self;
[viewBookmarkViewController setBookmark:[webView stringByEvaluatingJavaScriptFromString:@"document.title"]
url:self.url];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:viewBookmarkViewController] autorelease];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.bookmarkPopoverController = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[self.bookmarkPopoverController presentPopoverFromBarButtonItem:button
permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp
animated:YES];
} else {
[self presentModalViewController:navController animated:YES];
}
}
}