是的,UIAlertView
可能就是你要找的.下面是一个示例:
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,你可以在init
方法中创建UIAlertView
的子类并加入自定义UI组件.如果你想在UIAlertView
出现后对按钮按下做出react ,你可以在上面设置delegate
并实现- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
方法.
你可能还想看看UIActionSheet
.