如何在隐藏UITabBar的时候添加观察器(通过'hides-bottom-bar-when-pushing')?我有一个自定义按钮,位于我的标签栏下方,我想确保它在隐藏UITabBar时不会出现。谢谢!UITabBar从代理隐藏时观察
3
A
回答
1
的最好的选择是把你的UIToolbar
在启用了剪辑的UIView
中,并将剪辑视图放置在UITabBar
的上方。然后添加这个UIView
作为您的UITabBar
的子视图。这种方式显示和隐藏UITabBar
将自动显示或隐藏您的UIToolbar
现在您可以动画显示和隐藏您的UIToolbar
,并且每次UITabBar
时仍然会消失。
3
尝试使用UINavigationControllerDelegate protocol:
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if (viewController.hidesBottomBarWhenPushed) {
// ...
}
}
-1
这会告诉你的时候该字段的值更改:
UITabBar *myTabBar = [[UITabBar alloc] init];
[self addObserver:myInterestedObjectWhoWantsToKnowWhenTabBarHiddenChanges
forKeyPath:@"myTabBar.hidesBottomBarWhenPushed"
options:NSKeyValueObservingOptionNew
context:nil];
然后在myInterestedObjectWhoWantsToKnowWhenTabBarHiddenChanges.m,实现
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if ([keyPath isEqualToString:@"myTabBar.hidesBottomBarWhenPushed"]) { // this key must match, where observer is set.
// object will be "self" from the code above
// and the change dictionary will have the old and new values.
}
}
+0
实际上不起作用。 – Andy 2015-04-10 15:38:49
相关问题
- 1. 我如何观察UITabBar被隐藏的事件?
- 2. 隐藏UITabBar?
- 3. 隐藏的UITabBar
- 4. 隐藏基于观察到的阵列
- 5. 点击观察者隐藏图层
- 6. 横向隐藏UITabBar
- 7. UIPageControl隐藏在UITabBar
- 8. UITabBar不会隐藏
- 9. UIKit自定义UITabBar的外观代理
- 10. 防止UITabBar在推送时隐藏
- 11. 旋转设备时隐藏UITabBar iPhone
- 12. 可观察到的不更新时在一个隐藏的div
- 13. UITableView部分隐藏UITabBar
- 14. 隐藏自定义UITabBar
- 15. 隐藏并显示UITabbar
- 16. 使用ES6代理观察对象
- 17. 观察者隐含有
- 18. 从观察
- 19. 从代码隐藏
- 20. 从代码隐藏
- 21. 从代码隐藏
- 22. 从代码隐藏
- 23. 从代码隐藏
- 24. 从代码隐藏
- 25. 从代码隐藏
- 26. 从代码隐藏到隐藏字段
- 27. 观前UITabBar
- 28. iOS如何隐藏UITabBar和UINavigationController而不隐藏它们?
- 29. 使用可观察到隐藏导航栏在角2
- 30. 清除可观察的内容以隐藏knockout.js中的内容
UITabBarController中的tabbar是只读的,你怎么能在它上面添加一个子视图? – user392412 2012-02-24 06:43:19