我添加了UIScrollView
UIView
作为子视图。现在,当我触摸视图时,如何打开新视图?
我希望新视图出现。之前我的视图上有按钮...所以按钮的方法是“addtarget perform selector”...我正在加载新视图
这是我的观点图片
答案 0 :(得分:1)
例如,尝试以下代码(将其添加到您的视图中):
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
NSUInteger tapCount = [touch tapCount];
CGPoint location = [touch locationInView:self.view];
switch (tapCount)
{
case 1:
{
UIView *view = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:view];
[view release];
}
break;
}
}