同一视图中的多点触控和按钮

时间:2012-02-14 09:43:52

标签: objective-c ios button multi-touch

嗨,我有一个支持多点触控的应用程序UIViewController,也有一些按钮,我需要的是当用户双击按钮时会打开一个新视图,当用户在屏幕上移动时,它会打开其他视图。 / p>

如果用户将手指放在没有按钮的区域,该应用程序工作正常,但如果他将手指放在有按钮的区域没有任何事情发生

- (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];
}

1 个答案:

答案 0 :(得分:0)

将UIButton对象的userInteractionEnabled属性设置为NO并尝试。