问题描述
计算后,我想显示一个弹出框或警告框,向用户传达消息.有谁知道我在哪里可以找到有关这方面的更多信息?
After a calculation, I want to display a pop up or alert box conveying a message to the user. Does anyone know where I can find more information about this?
推荐答案
是的,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
.
这篇关于iOS中如何实现弹出对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!