gpt4 book ai didi

iphone - 单个 View 中的多个警报 View ?

转载 作者:行者123 更新时间:2023-12-03 19:41:35 24 4
gpt4 key购买 nike

我有一个 Iphone 应用程序,当我按下按钮时,它会显示一个警报 View 来选择背景。用户选择的任何背景都将作为音频剪辑的背景播放。但现在我需要在之前添加另一个警报我显示此警报是为了发出一些警告。之后只需要弹出第二个警报。但是我已经在该 View Controller 的 didappear 中选择警报并将其设置为 Uialertview 委托(delegate)。并且在我正在执行的按钮操作上不同的行动。任何人都可以帮助我实现这一目标吗?

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

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

实现委托(delegate)方法

-(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.
}
}
}

Controller 类 header

@interface ViewController : UIViewController<UIAlertViewDelegate>{

}

希望这能满足您的需求!

关于iphone - 单个 View 中的多个警报 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10848202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com