更新时间:2023-01-24 12:14:34
是的,UIAlertView
可能就是您要找的.这是一个例子:
Yup, a UIAlertView
is probably what you're looking for. Here's an example:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
如果你想做一些更花哨的事情,比如在 UIAlertView
中显示自定义 UI,你可以继承 UIAlertView
并在 中放入自定义 UI 组件初始化
方法.如果要在 UIAlertView
出现后响应按钮按下,可以设置上面的 delegate
并实现 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
方法.
If you want to do something more fancy, say display a custom UI in your UIAlertView
, you can subclass UIAlertView
and put in custom UI components in the init
method. If you want to respond to a button press after a UIAlertView
appears, you can set the delegate
above and implement the - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
method.
您可能还想查看 UIActionSheet
.