在iPhone中我已经知道navigationbarbutton触摸也有一些扩展在导航栏下,但我需要限制用户交互只有一定的限制。我可以做到这一点。任何人都可以帮助我吗?限制导航栏按钮项中的触摸区域?
1
A
回答
0
实现轻击手势识别器并将您的控制器设置为委托。然后执行:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// [touch locationInView] -> gives the point where the user touched
// If the touch point belongs to your frame then return YES
// else return NO
}
0
可以实现自定义导航栏自己与隐藏的导航栏的“引擎”背后,让按钮上的自定义导航栏与所需的自定义行为/视觉效果。 如果您想实现手势逻辑(平移)切换导航页面,这也很有用。
AppDelegate.h:
@property (strong, nonatomic) UINavigationController *navigationController;
AppDelegate.m:
YourMainViewController *yourmainViewController = [[YourMainViewController alloc] init];
_navigationController = [[UINavigationController alloc] yourmainViewController];
[_navigationController setNavigationBarHidden:TRUE];
[self.window setRootViewController:_navigationController];
[self.window makeKeyAndVisible];
YourMainViewController.m:实现自定义导航图像和添加按钮,您的视图使用Interface Builder编程或导航无论是。例如编程方式创建视图:
- (void)loadView {
...
UIImageView *tmp_mynavbar = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CustomNavBG.png"]];
tmp_mynavbar.frame = CGRectMake(0, 0, 320, 44);
[self.view addSubview:tmp_mynavbar];
UIButton *tmp_addbutton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tmp_addbutton.frame = CGRectMake(260, 10, 40, 20);
[tmp_addbutton setTitle:@"Add" forState:UIControlStateNormal];
[tmp_addbutton setBackgroundImage:[UIImage imageNamed:@"CustomNavAddBtn.png"] forState:UIControlStateNormal];
[tmp_addbutton addTarget:self action:@selector(pressedbuttonAddItem:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tmp_addbutton];
// create button with the required size, user interaction area (add image then add transparent button with different size, etc)
// also add a back button
...
}
然后实现自定义导航按钮行为(添加/前进按钮也后退按钮)
-(void) pressedbuttonAddItem:(id) sender {
AppDelegate *app = (AppDelegate*) [[UIApplication sharedApplication] delegate];
DetailViewController *detailViewController = [[DetailViewController alloc] init];
[[app navigationController] detailViewController animated:YES];
}
-(void) pressedbuttonBack:(id) sender {
AppDelegate *app = (AppDelegate*) [[UIApplication sharedApplication] delegate];
[[app navigationController] popViewControllerAnimated:YES];
}
相关问题
- 1. Cocos2d按钮触摸区域
- 2. 如何扩展按钮触摸区域?
- 3. 用sencha触摸按钮导航
- 4. 导航栏按钮
- 5. 触摸区域控制
- 6. 限制在iPhone中的UIButton的可触摸区域?
- 7. 按钮不显示在导航栏项
- 8. IOS 11导航栏按钮项目
- 9. 定制后退按钮在导航栏
- 10. 定制导航栏隐藏按钮
- 11. 导航栏中的左栏按钮项目
- 12. iphone 2按钮导航栏
- 13. jQuery和导航栏按钮
- 14. 更改导航栏按钮
- 15. 导航栏和按钮
- 16. 导航带后退按钮的左栏按钮项目
- 17. 设置左侧按钮的重用导航栏项目按钮
- 18. jquery触摸导航
- 19. iOS:在自定义导航栏中定位导航栏按钮
- 20. 导航抽屉打开时,工具栏按钮不响应触摸
- 21. iphone - 如何扩展按钮的触摸区域?
- 22. 可触摸区域(iPad)上的悬停按钮状态
- 23. 设置栏按钮项目作为导航控制器上的后退按钮
- 24. 无法在导航栏中设置左栏按钮项目?
- 25. 在自定义导航栏中设置栏按钮项颜色
- 26. 限制UIButton的触摸到指定区域
- 27. 隐藏导航栏中的按钮
- 28. 导航栏中的按钮颜色 - iPhone
- 29. 导航栏中按钮的新活动
- 30. IOS半透明导航栏,但坚实的导航栏按钮
一个快速的想法:使用可以把透明'UIView'所以你不能碰那部分! – Maulik 2013-03-14 07:40:17
@maulik我有一个按钮只是在唠叨bar.so当我触摸该按钮有时导航栏按钮被调用... – hacker 2013-03-14 07:42:50
然后,我想你必须改变按钮位置 – Maulik 2013-03-14 07:43:40