gpt4 book ai didi

iPhone - 嵌套在 UIView 中的 UIbutton 不响应该 View 动画后的触摸

转载 作者:行者123 更新时间:2023-12-03 18:45:58 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com