【发布时间】:2012-02-14 09:43:51
【问题描述】:
嗨,我有一个应用程序 UIViewController,它支持多点触控并且也有一些按钮,我需要的是当用户双击按钮时它会打开一个新视图,而当用户在屏幕上移动手指时它会打开另一个视图。
如果用户将手指放在没有按钮的区域,应用程序可以正常工作,但如果他将手指放在有按钮的区域,则没有任何反应
- (void)viewDidLoad
{
[super viewDidLoad];
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(openPic:)
forControlEvents:UIControlEventTouchDownRepeat];
button.tag = image;
button.frame = CGRectMake(orInc, inc, 70.0, 95.0);
[self.view addSubview:button];
]
-(void) openPic:(id)sender {
UINavigationController *nav=[[UINavigationController alloc]init];
PicController *x=[[PicController alloc]init];
nav.viewControllers=[NSArray arrayWithObject:x];
[self.navigationController pushViewController:x animated:YES];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UINavigationController *nav=[[UINavigationController alloc]init];
ViewController *x=[[ViewController alloc]init];
nav.viewControllers=[NSArray arrayWithObject:x];
[self.navigationController pushViewController:x animated:YES];
}
【问题讨论】:
标签: objective-c ios button multi-touch