http://www.idev101.com/code/User_Interface/UIAlertView.html
Alert views are pop-up views that appear over the current view on the iPhone.
Creating and showing an alert (ARC compatible):
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];
For non-ARC (retain/release) projects, you must autorelease the alert view:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];
If you add the UIAlertViewDelegate protocol to your controller, you can also add the following method which is called after the user dismisses the alert view:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { // do stuff } }
Button indices start at 0 (for the cancelButton specified in the alloc/init), and go up by 1 for each addButtonWithTitle call you add. If you have a lot of alerts, your didDismiss method can keep track of which one is being dismissed if you add the setTag call to the alert initialization: [alert setTag:23];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"I'm sorry Dave, I'm afraid I can't do that." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [alert setTag:12]; [alert show]; ... later ... - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if ([alertView tag] == 12) { // it's the Error alert if (buttonIndex == 0) { // and they clicked OK. // do stuff } } }
相关推荐
自定义alertview,一款封装好的自定义alertview控件,多样化alertview的使用
下方主要使用代码: 这是添加的方法: ConfigueAlertView *alertView = [[ConfigueAlertView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)withGroupNumber:10]; alertView.delegate = ...
IOS alertView控件如何添加文本框以及密码框,很实用的几行代码
iOS8.0之后,apple推出UIAlertController,该资源对AlertView及AlertController的封装,使之满足在不同的系统版本下,自动选择应使用哪种控件,来完成我们所需要的功能,并且避免apple为我们挖的一些坑
适配ios7,ios6的弹框AlertView,强大
FCAlertView是一个用于iOS的扁平可定制AlertView(用Objective C编写)
自定义环形进度条,可根据自己设定的状态显示百分比,文字,颜色,半径大小,进度条是以0点为起点顺时针方向旋转。
弹窗控件:支持AlertView、Sheet、自定义视图的PopupView。AlertView中可以嵌套自定义视图,各组件的显示隐藏可配置;Sheet仿微信样式;同时提供自定义弹出。更多配置请参考”可设置参数“,提供OC使用Demo.zip
iPhone开发【四】常用控件之ActionSheet与AlertView
HDAlertView是一个类似系统alertView弹窗。 系统自带UIAlertView有常见BUG, 比如和系统键盘动画冲突... 使用UIAlertController就不会有UIAlertView等等问题, 但是又不支持iOS7.所以才自定义一个类似系统的UIAlertView
IOS之弹窗-Swift4.2 /使用说明: 1、弹窗基类分别使用了OC和Swift来实现,同时OC和Swift版本分别实现了几个不同的弹窗效果;2、Objective-C类需要继承弹窗基类时必须选择该库的Objective-C版本中的基类;3、两个库...
iOS开发之UIlabel多行文字自动换行 (自动折行) UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(10, 100, 300, 180)]; UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 300, ...
//超出这个view的边界的控件不再显示 [_infoView setClipsToBounds:YES]; //UIView 静态方法,开始一个动画 [UIView beginAnimations:nil context:nil]; begin 开始 //animation 动画 duration 间隔时间 ...
iOS9.0之后,UIAlertView和UIActionSheet已经不建议使用,但还未彻底废弃。alert提示窗可以算得上是十分常用的UI控件了,基于上述情况,考虑到版本兼容,笔者将上述控件进行了简单的整合封装。封装之后,只需一句话...
Alert 在iOS开发中,是一个经常用到的控件。iOS原生的API中的写法,我这里就不吐槽了,无论是AlertView 还是AlertViewcontroller 都需要很多代码来调用。
作者Lafree317,源码customAlertView,遍历构造器又称工厂方法,可以把一个或多个控件封装到一个类中,每次创建控件只需要调用方法就可以了,本次我所说的就是封装一个根据所输入的数组进行自动创建提示框的类。
类系统控件,可以方便的替换项目中的alertview,满足项目实战。 具体使用: LCAlertView *alert = [[LCAlertView alloc]initWithTitle:@"提示" message:@"你没吃早饭吧?" delegate:self cancelButtonTitle:@"取消...
来源:github/CXAlertViewLicence:MIT平台:iOS设备:iPhone / iPad作者:Chris Xu 可以高度自定义的AlertView。...除此,还可以在AlertView中加入各种控件,包括图片、滚动视图、文字视图等等,十分灵活。
这是一款实现了自定义对话框的效果源码,该效果的源码比较简单的,效果实现在AlertView底部左右滑动显示更多按钮的特效,所以理论上可以在对话框中加入任意多个按钮,另外还可以在对话框中加入各种控件,包括图片、...