I've been working on my book app, but I have a UIBarButtonItem dilemma. I have set the 3 bar buttons on the toolbar as you can see in the image below. They work fine until I set the single tap recognizer, the last 2 lines in the code. What I want to do is get out of this modal screen by a single tap, not a double tap, not by adding another 'Cancel' button on the toolbar. After I set the single tap recognizer, none of the bar button items work. How can I get out of this dilemma. Can any one tell me how to get around this? Thank you for your time.
UIToolbar* toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
[toolbar sizeToFit];
toolbar.frame = CGRectMake(0, 410, 320, 50);
toolbar.tintColor = _label.backgroundColor;
self.title = @"Test For Toolbar";
UIBarButtonItem* TofC = [[UIBarButtonItem alloc] initWithTitle:@"T of C"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(showTofC)];
UIBarButtonItem* bookMark =
[[UIBarButtonItem alloc] initWithTitle:@"Book Mark"style:UIBarButtonItemStyleBordered
target:self
action:@selector(bookMarkIt)];
UIBarButtonItem* searchBtn = [[UIBarButtonItem alloc] initWithTitle:@"Search"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(searchIt)];
UIBarButtonItem* spacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:self
action:nil];
NSArray* buttons =
[NSArray arrayWithObjects:TofC, spacer, bookMark, spacer, searchBtn, nil];
self.navigationController.toolbarHidden = NO;
[toolbar setItems:buttons animated:NO];
[self.view addSubview:toolbar];
/*
// Single Tap
UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleTapGesture:)];
[self.view addGestureRecognizer:tapGesture];
*/
// Single Tap
Dum2ViewController* dum2ViewController = [[Dum2ViewController alloc] init];
UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc]
initWithTarget:dum2ViewController
action:@selector(handleTapGesture:)];
[dum2ViewController.view addGestureRecognizer:tapGesture];