gpt4 book ai didi

iphone - iphone 中的警报 View

转载 作者:太空狗 更新时间:2023-10-30 03:10:58 26 4
gpt4 key购买 nike

我是 iPhone 应用程序开发的新手。我想设计一个带有 2 个按钮的警报 View :OKCancel。当用户触摸 OK 按钮时,我将打印一条消息,内容为 hello。当他们触摸 Cancel 按钮时,我将打印 cancel

请帮忙;我该怎么做?

最佳答案

显示警报:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Do you want to say hello?"
message:@"More info..."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Say Hello",nil];
[alert show];
[alert release];

响应点击的任何按钮:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"Cancel Tapped.");
}
else if (buttonIndex == 1) {
NSLog(@"OK Tapped. Hello World!");
}
}

有关详细信息,请参阅 UIAlertView Class ReferenceUIAlertView Delegate Protocol Reference .

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

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