Iphone 一个视图中有多个AlertView?

Iphone 一个视图中有多个AlertView?,iphone,Iphone,我有一个Iphone应用程序,当我按下一个按钮时,它会显示一个alertview来选择背景。无论用户选择哪种背景,都将作为音频剪辑的背景播放。但是现在我需要在显示此警报之前添加另一个警报,以提供一些警告。之后,我只需要弹出第二个警报。但是我在viewcontroller的显示窗口中选择alert并将其设置为Uialertview代理。在按钮操作上,我正在执行不同的操作。有人能帮我实现这一点吗 proAlertView *loginav1=[[proAlertView alloc] initWit

我有一个Iphone应用程序,当我按下一个按钮时,它会显示一个alertview来选择背景。无论用户选择哪种背景,都将作为音频剪辑的背景播放。但是现在我需要在显示此警报之前添加另一个警报,以提供一些警告。之后,我只需要弹出第二个警报。但是我在viewcontroller的显示窗口中选择alert并将其设置为Uialertview代理。在按钮操作上,我正在执行不同的操作。有人能帮我实现这一点吗

proAlertView *loginav1=[[proAlertView alloc] initWithTitle:@"title" message:@"Choose a Background to play with this program?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Field",@"Beach", @"Stars",nil];
[loginav1 setBackgroundColor:[UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha:1.0] withStrokeColor:[UIColor colorWithHue:0.625 saturation:0.0 brightness:0.8 alpha:0.8]];




[loginav1 show];
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons




if (buttonIndex == 0)
{
    //[self play];
    //moviePlayer.scalingMode=MPMovieScalingModeAspectFill;

    if(actionSheet.tag==123)
    {
        [self backButtonPressed];
    }




}
else if (buttonIndex == 1)
{

     videoFile = [[NSBundle mainBundle] pathForResource:@"video-track" ofType:@"mp4"];
    [self play];
    moviePlayer.scalingMode=MPMovieScalingModeAspectFill;



}

如何在这成为我的问题之前包含另一个警报?

您可以这样做,首先在alertview中显示警告消息,当用户在alertview中单击“确定”,然后在alertview委托方法中编写代码以显示第二个alertview,用户可以在其中选择背景。

初始化第一个alertview

UIAlertView *al1 = [[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Warning Msg!!!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
al1.tag=1;
al1.delegate=self;
[al1 show];
实现委托方法

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(alertView.tag==1){
        // implement button events for first Alertview
        if(buttonIndex==1){
            //First button clicked of first Alertview
            UIAlertView *al2 = [[UIAlertView alloc] initWithTitle:@"Choose BG" message:@"Choose BG?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"1",@"2",@"3", nil];
            al2.tag=2;
            al2.delegate=self;
            [al2 show];
        }

    }

    if(alertView.tag==2){
        // implement button events for second Alertview
        if(buttonIndex==1){
            // First button clicked second Alertview.
        }
    }
}
控制器类标题

@interface ViewController : UIViewController<UIAlertViewDelegate>{

}
@界面ViewController:UIViewController{
}

希望这能满足你的需要

现在我用3个按钮处理代理中的选择警报。我如何将这些操作包括在警告的ok按钮操作中?我清楚地表明,在选择bg消息之前,我需要给出一个简单的警告消息。你所做的是在选择bg消息之后再选择另一个消息。这不是我想要抱歉,但你可以切换这提醒了我的看法!使用“al1”进行警告,当用户按下“al1”的“Ok”按钮时,打开“al2”选择BG声音。