Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将iAction添加到UIAlert_Iphone_Xcode_Ios4_Xcode4 - Fatal编程技术网

Iphone 将iAction添加到UIAlert

Iphone 将iAction添加到UIAlert,iphone,xcode,ios4,xcode4,Iphone,Xcode,Ios4,Xcode4,我试图让UIAlert在单击按钮时执行两种不同的操作。当用户单击“重新启动”时,游戏将重新启动,当单击主菜单时,游戏将转到主菜单。“重置”按钮工作正常,但IBAction在切换视图时不断给我错误信息 // called when the player touches the "Reset Game" button - (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

我试图让UIAlert在单击按钮时执行两种不同的操作。当用户单击“重新启动”时,游戏将重新启动,当单击主菜单时,游戏将转到主菜单。“重置”按钮工作正常,但IBAction在切换视图时不断给我错误信息

// called when the player touches the "Reset Game" button
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if (buttonIndex == 0)
    {
        [self resetGame];
    }
    else
    {
        - (IBAction)showFlip:(id)sender {
            Menu *menuView = [[[menu alloc] init] autorelease];
            [gameView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
            [self presentModalViewController:menuView animated:YES];

        }

    }



    }
重置工作正常,但我在iAction上遇到两个错误。”showFlip“未声明(首次在此函数中使用)和预期”;”在“:”标记之前。我不明白为什么会这样说,因为当我在alertview之外发布IBAction时,它工作正常。
任何帮助都将不胜感激,请提前感谢

您正在定义一个方法,而不是调用一个!此代码

- (IBAction)showFlip:(id)sender {
            Menu *menuView = [[[menu alloc] init] autorelease];
            [gameView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
            [self presentModalViewController:menuView animated:YES];

        }
不应存在于此函数中。把它拔出来

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if (buttonIndex == 0)
    {
        [self resetGame];
    }
    else
    {
        [self showFlip];
    }
}

-(void)showFlip{
    Menu *menuView = [[[menu alloc] init] autorelease];
    [gameView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentModalViewController:menuView animated:YES];
}
你应该试试这个:

// called when the player touches the "Reset Game" button
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if (buttonIndex == 0)
    {
        [self resetGame];
    }
    else
    {
        [self showFlip:nil];
    }
}

- (IBAction)showFlip:(id)sender {
    Menu *menuView = [[[menu alloc] init] autorelease];
    [gameView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentModalViewController:menuView animated:YES];
}

谢谢这就成功了,正如你可能知道的那样,我对这东西还很陌生。