我有一个 UIView(视图 B),上面有一个 UIButton。
我将此视图 B 添加到主视图边界之外的区域中的主视图(视图 A),然后使用 UIView 动画对其进行动画处理。
UIView 动画完成后,视图 B 现在位于视图 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];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)