gpt4 book ai didi

ios - 警报 View 按钮

转载 作者:行者123 更新时间:2023-12-01 17:19:45 25 4
gpt4 key购买 nike

我正在创建一个iOS应用程序,当分数达到100时,将显示此警报,并且一切正常,但是按钮(共享,苹果,为该应用程序评分)。

     - (void) buttonAction {
counter++;
if(counter == 100)
[self showAlert];
}

- (void) showAlert {

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"hello"
message:@"whats you name"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:@"share", @"apple" , @"rate this app", nil];


-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) { // means share button pressed
// write your code here to do whatever you want to do once the share button is pressed
}
if(buttonIndex == 1) { // means apple button pressed
// write your code here to do whatever you want to do once the apple button is pressed
}
// and so on for the last button
}

[alert show];



}

-(IBAction)plus {
counter=counter + 1;
count.text = [NSString stringWithFormat:@"%i",counter];
if(counter == 100)
[self showAlert];

}

-(IBAction)zero {
counter=0;
count.text = [NSString stringWithFormat:@"%i",counter];
}



- (void)viewDidLoad {
counter=0;
count.text = @"0";
[super viewDidLoad];

}

我不想要什么,我在哪里添加链接等。谢谢

最佳答案

尝试以下...

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"hello"
message:@"whats you name"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:@"share", @"apple" , @"rate this app", nil];

[alert show];

然后在您的代码中添加以下方法:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) { // means share button pressed
// write your code here to do whatever you want to do once the share button is pressed
}
if(buttonIndex == 1) { // means apple button pressed
// write your code here to do whatever you want to do once the apple button is pressed
}
// and so on for the last button
}

一个建议,如果您在问题中更清楚地知道自己想做什么,您可能会得到更多有用的答案...

希望能帮助到你

关于ios - 警报 View 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11483465/

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