How to implement a pop-up dialog box in iOS?(iOS中如何实现弹出对话框?)
问题描述
计算后,我想显示一个弹出框或警告框,向用户传达消息.有谁知道我在哪里可以找到有关这方面的更多信息?
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中如何实现弹出对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS中如何实现弹出对话框?


基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01