gpt4 book ai didi

iphone - 使用事件指示器和标签显示警报(可变)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:53 29 4
gpt4 key购买 nike

i make a game that start display Activity indicator And activity indicator bottom display UiLable with text is :-Ready after 2 Sec lable text is:-Set And After 2 Sec lable text is:- Go.

now i use a 3 different alert to display this.

Can i do this with only one alert

最佳答案

我想你想要这种类型的警报 enter image description here

做这个试试这个

在 .h 文件中

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
IBOutlet UILabel *Lable;
NSTimer *Timer1;
NSTimer *Timer2;
UIActivityIndicatorView *Process;
UIAlertView *Game;
}
-(IBAction)start:(id)sender;

@end

在 .M 文件中

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
int i;

- (void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)start:(id)sender
{
i=0;
Game=[[UIAlertView alloc]initWithTitle:@"Please Wait" message:@"\n" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
Process=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
Process.frame=CGRectMake(129, 50, 30, 27);
[Process startAnimating];


Lable=[[UILabel alloc]initWithFrame:CGRectMake(102, 80, 80, 30)];
Lable.text=@"Ready";
Lable.backgroundColor=[UIColor clearColor];
Lable.textColor=[UIColor whiteColor];
Lable.textAlignment= UITextAlignmentCenter;
[Game addSubview:Lable];
[Game addSubview:Process];
[Game show];
Timer1 = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(Change) userInfo:nil repeats:NO];
}
-(void)Change{
Timer2 = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(Change) userInfo:nil repeats:NO];
if (i==0)
Lable.text=@"Set";
else
Lable.text=@"Go";

i++;
if (i==3) {
[Timer2 invalidate];
Timer2=nil;
[Process stopAnimating];
[Game dismissWithClickedButtonIndex:0 animated:YES];

}
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

关于iphone - 使用事件指示器和标签显示警报(可变),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15634236/

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