UIAlet中的问题

时间:2010-10-21 05:33:01

标签: iphone

我正在创建我的第一个iphone应用程序,但现在面临很多问题..我正在尝试使用一个警告窗口,其中包含是和否。当我点击它不会它应该保留在同一个屏幕上然而当我点击是的它应该带我到另一个屏幕,但我无法做到是的部分。我的代码看起来像这样..

-(IBAction)buttonPressedid)sender
{
NSString *TITLE = [[NSString alloc] initWithFormat: @"Do you want to add the ingredient to your Grocery list"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message" 
message:TITLE 
delegate:nil
cancelButtonTitle:@"No" 
otherButtonTitles:@"YES",nil];

因此,当我点击是时,它应该带我到另一个屏幕。我该怎么做?

请帮忙......

2 个答案:

答案 0 :(得分:2)

你需要UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

了解更多细节阅读以下教程

http://mobile.tutsplus.com/tutorials/iphone/uialertview/

答案 1 :(得分:0)

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@“Game Over”消息:nil delegate:self cancelButtonTitle:@“Quit”otherButtonTitles:@“Restart”,nil];     alert.tag = 1;     [警示显示];     [警告发布];

pragma mark AlertView委托方法

  • (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(alertView.tag == 3){     if(buttonIndex == 0){         出口(0);     }     其他{         [UIView beginAnimations:nil context:NULL];         [UIView setAnimationDuration:1.5];
            [UIView setAnimationDelegate:self];         [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];         [self viewWillAppear:YES];         [UIView commitAnimations];

        appDelegate.winningAmount = nil;
        encylCount = 0;
        googleCount = 0;
        mGoogleButton.userInteractionEnabled = YES;
        mEncyclopediaButton.userInteractionEnabled = YES;
    }
    

    }

}