我已经创建了一个应用程序,我想在其中使用touchBegind方法。为此,我使用了以下代码:


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //Get all the touches.
    NSSet *allTouches = [event allTouches];

    //Number of touches on the screen
    if([allTouches count] > 0 && self.view!=comparedView.view)
    {
        //Navigate to next screen here likewise you generally do

        ActionViewController *actController = [[ActionViewController alloc] init];
        UINavigationController *nvController = [[UINavigationController alloc]
                                                initWithRootViewController:actController];
        nvController.navigationBarHidden = YES;
        CGRect frame = [[nvController navigationBar] frame];
         frame = CGRectMake(0.0,0.0, 320.0, 460.0);
        [[nvController navigationBar] setFrame:frame];
        [self setView:[nvController view]];
        [actController release];

    }

}

触摸屏幕上我的第一个视图的任何地方,将执行以下代码并转到下一个视图。但问题是,当我转到最后一个视图并在该视图中触摸imageview时,会调用上面的方法。
我不知道事情是怎么发生的。

最佳答案

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 每次都会被调用,直到视图控制器被释放或触摸事件被禁用。
每次创建视图并将其添加到同一个视图控制器时,touch beganis都会调用所有视图

关于iphone - 触摸开始方法问题?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5295283/

10-12 00:15
查看更多