UIAlertView Class 和UIAlertViewDelegate Protocol

来源:互联网 发布:微信返利机器人源码 编辑:程序博客网 时间:2024/06/05 06:14

UIAlertView Class

 

继承自

UIView:UIResponder:NSObject

遵循协议

NSCoding(UIView)

NSObject(NSObject)

框架

/System/Libaray/Frameworks/UIKit.framework

支持

iOS 2.0 及以后

声明

UIAlertView.h

相关实例代码

AdvancedURLConnections

GKRocket

GKTank

LaunchMe

UICatalog

 

 

概述

使用UIAlertView类显示一个警告信息给用户。 Alert 视图的函数与UIActionSheet相似,只是名称不同。

使用该类实例的属性和方法可以设置警告视图的标题(title),消息(message),委托对象(delegate)和按钮们(buttons)。如果你添加自定义按钮,你必须设置一个遵循UIAlertViewDeleagate协议的委托对象(delegate)。配置完成一个alert view后,使用show方法显示之。

 

重要:在IOS4.0及以后,当一个应用程序转到后台后,alert view 不会被自动解除。

 

实例方法:

 

//添加一个按钮

-(NSInteger) addButtonWithTitle:(NSString*)title

 

//返回按钮标题

-(NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex

 

//设置解除

-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndexanimated:(BOOL) animated

 

//初始化

-(id) initWithTitle:(NSString *)titlemessage:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString*)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles,…

 

//显示

-(void) show

 

 

属性:

//取消按钮索引

@property(nonatomic) NSInteger cancelButtonIndex

 

//委托对象:遵循UIAlertViewDelegate协议

@property(nonatomic, assign) id delegate

 

//第一个其他按钮索引

@property(nonatomic, readonly) NSIntegerfirstOtherButtonIndex

 

//消息

@property(nonatomic, copy) NSString *message;

 

//按钮数量

@property(nonatomic, readonly) NSIntegernumberOfButtons

 

//标题

@property(nonatomic, copy) NSString * tilte

 

//是否可视

@property(nonatomic, readonly,getter=isVisible) BOOL visible

 


UIAlertViewDelegate Protocol

 

遵循

NSObject

框架

/System/Libaray/Frameworks/UIKit.framework

支持

iOS 2.0 及以后

声明

UIAlertView.h

相关实例代码

GKRocket

GKTank

LaunchMe

UICatalog

URLCache

 

实例方法:

 

//点击按钮-完成

-(void) alertView:(UIAlertView *)alertViewclickedButtonAtIndex:(NSInteger)buttonIndex

 

 

//点击按钮解除视图-完成

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

 

 

//点击按钮解除视图-将要

-(void)alertView:(UIAlertView *)alertViewwillDismissWithButtonIndex:(NSInteger)buttonIndex

 

 

//将要被取消

-(void)alertViewCancel:(UIAlertView *)alertView

 

-(void)didPresentAlertView:(UIAlertView *)alertView

 

-(void)willPresentAlertView:(UIAlertView *)alertView




原创粉丝点击