0
我一直在研究我的圖書應用程序,但是我有一個UIBarButtonItem困境。我已經在工具欄上設置了3個按鈕,如下圖所示。它們工作正常,直到我設置了代碼中最後2行的單擊識別器。我想要做的是通過一次敲擊跳出此模式屏幕,而不是雙擊,而不是在工具欄上添加另一個「取消」按鈕。設置了單擊識別器後,沒有任何條形按鈕項目可以工作。我怎樣才能擺脫這種困境。任何人都可以告訴我如何解決這個問題嗎?感謝您的時間。toolbaritem的困境
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];
嗨,謝謝你的建議。我喜歡你的建議,但不是運氣。請看看我上面添加的代碼。再次感謝。 – boochan224