【发布时间】:2012-07-20 06:50:43
【问题描述】:
我正在尝试在我的应用程序中实现一个可隐藏的 UITabBar。我已经设置了所有的动画,它们工作得很好。我只是在让我的 UIButton “pull-tab” 显示标签栏时遇到问题。它没有响应触摸事件 UIControlEventTouchUpInside。 我将下拉选项卡添加到 UITabBarController 中的 UITabBar:
- (void)viewDidLoad
{
[super viewDidLoad];
//Add pull
pullButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"TabBarPull.png"];
pullButton.frame = CGRectMake(self.tabBar.frame.size.width - image.size.width, -image.size.height + 3, image.size.width, image.size.height);
[pullButton setImage:image forState:UIControlStateNormal];
[pullButton addTarget:self action:@selector(pullBarTapped:) forControlEvents:UIControlEventTouchUpInside];
pullButton.userInteractionEnabled = YES;
[self.tabBar addSubview:pullButton];
}
这是标签栏打开和关闭的样子:
编辑:我确定问题是因为按钮位于 UITabBar 的框架之外。看起来我将不得不将按钮放在 UITabBar 之外......动画噩梦。
【问题讨论】:
-
好吧,你可以继承 UITabBar 的可能性,弄清楚如何让你的子类在 UITabBarController 中使用(子类它),然后在你的 UITabBar 子类中创建一个更大的框架,让 UITabbar 使用它的正常框架,但现在你的子类应该得到所有的水龙头等。如果是我,我会首先尝试在演示项目中只做 UITabBar 子类,只有当它工作时才尝试让它与所有其他机器一起工作。祝你好运!
-
@Brandon Mcq 嘿,我也在寻找同样的东西——你有没有想出一个好的解决方案?谢谢!
-
@Brandon Mcq 刚看到你的 github,看看那个谢谢!
标签: ios uiview uibutton uitabbarcontroller uitabbar