作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UIView( View B),上面有一个 UIButton。
我将此 View B 添加到主视图边界之外的区域中的主视图( View A),然后使用 UIView 动画对其进行动画处理。
UIView 动画完成后, View B 现在位于 View A 之上,因此按钮可见,按钮不会响应触摸...我以前从未见过这种情况,但这是我正在做的第一个应用程序与新的 iOS (iOS 5) 一起使用。有什么想法吗?
提前致谢。
最佳答案
这是您所描述的情况吗?因为它看起来工作得很好。您是否检查了 UIView 上的 userInteractionEnabled 是否设置为 YES?
- (void)buttonPressed:(UIButton*)button
{
NSLog(@"button pressed");
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, -100, 100, 100)];
view.backgroundColor = [UIColor blackColor];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 10, 100, 20);
[view addSubview:button];
[self.view addSubview:view];
[UIView animateWithDuration:0.5 animations:^{
view.transform = CGAffineTransformMakeTranslation(0, 100);
}];
[view release];
}
关于iPhone - 嵌套在 UIView 中的 UIbutton 不响应该 View 动画后的触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7913157/
我是一名优秀的程序员,十分优秀!