0

如果 UIButton 的位置超出其超级视图但它是可见的,它可以响应触摸事件吗?

UIView *view01 = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
UIButton *button01 = [UIButton buttonWithStyle:UIButtonType:UIButtonTypeRoundedRect];
[button01 addTarget:self action:@selector(testTouch:) forControlEvents:UIControlEventTouchUpInside];
button01.frame = CGRectMake(0, 200, 60, 40);
[view01 addSubview:button01];

- (void)testTouch:(id)sender{
  NSLog(@"Touched.....");
}

…………

4

1 回答 1

0

您还需要添加view01到视图中。

于 2011-10-14T11:52:31.930 回答