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