I have created a button in my text field and calling my bookMarks method. That works fine with iphone. If I create a button in a toolbar and call this method, still works fine. it’s just not working in my text field. is there a way to fix this problem? Thanks..
[bookMarkButton addTarget:self action:@selector(bookMarks:) forControlEvents:UIControlEventTouchUpInside];
locationField.leftView = bookMarkButton;
bookMarks method
- (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];
}
}
}
Why don’t u add ControlEvent for textField:
EDIT: To differentiate buttons add Tag 0 and 1 to two buttons respectively;
Now your method is: