scrollview 的各类代理方法汇总

来源:互联网 发布:鳄鱼有耳朵吗 知乎 编辑:程序博客网 时间:2024/05/21 11:16
  1. Tasks 
  2.   
  3.  Creating Alert Views 
  4.     – initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:   
  5.  Setting Properties 
  6.     delegate  property   
  7.     title  property   
  8.     message  property   
  9.     visible  property   
  10.  Configuring Buttons 
  11.     – addButtonWithTitle:   
  12.     numberOfButtons  property   
  13.     – buttonTitleAtIndex:   
  14.     cancelButtonIndex  property   
  15.     firstOtherButtonIndex  property   
  16.  Displaying 
  17.     – show   
  18.  Dismissing 
  19.     – dismissWithClickedButtonIndex:animated:  无例 
  20. */  
  21.   
  22. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.  
  23. - (void)viewDidLoad {  
  24.     //初始化AlertView  
  25.     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"AlertViewTest"   
  26.                             message:@"message"   
  27.                             delegate:self   
  28.                             cancelButtonTitle:@"Cancel"   
  29.                             otherButtonTitles:@"OtherBtn",nil];  
  30.     //设置标题与信息,通常在使用frame初始化AlertView时使用  
  31.     alert.title = @"AlertViewTitle";  
  32.     alert.message = @"AlertViewMessage";  
  33.       
  34.     //这个属性继承自UIView,当一个视图中有多个AlertView时,可以用这个属性来区分  
  35.     alert.tag = 0;  
  36.       
  37.     //只读属性,看AlertView是否可见  
  38.     NSLog(@"%d",alert.visible);  
  39.       
  40.     //通过给定标题添加按钮  
  41.     [alert addButtonWithTitle:@"addButton"];  
  42.       
  43.     //按钮总数  
  44.     NSLog(@"numberOfButtons:%d",alert.numberOfButtons);  
  45.       
  46.     //获取指定索引的按钮的标题  
  47.     NSLog(@"buttonTitleAtIndex:%@",[alert buttonTitleAtIndex:2]);  
  48.       
  49.     //获得取消按钮的索引  
  50.     NSLog(@"cancelButtonIndex:%d",alert.cancelButtonIndex);  
  51.       
  52.     //获得第一个其他按钮的索引  
  53.     NSLog(@"firstOtherButtonIndex:%d",alert.firstOtherButtonIndex);  
  54.       
  55.     //显示AlertView  
  56.     [alert show];  
  57.       
  58.     [alert release];  
  59.     [super viewDidLoad];  
  60. }  
  61.   
  62. /* 
  63. // Override to allow orientations other than the default portrait orientation. 
  64. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
  65.     // Return YES for supported orientations 
  66.     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
  67. } 
  68. */  
  69. - (void)didReceiveMemoryWarning {  
  70.     // Releases the view if it doesn't have a superview.  
  71.     [super didReceiveMemoryWarning];  
  72.       
  73.     // Release any cached data, images, etc that aren't in use.  
  74. }  
  75. - (void)viewDidUnload {  
  76.     // Release any retained subviews of the main view.  
  77.     // e.g. self.myOutlet = nil;  
  78. }  
  79.   
  80. - (void)dealloc {  
  81.     [super dealloc];  
  82. }  
  83. #pragma mark  -- UIAlertViewDelegate --  
  84. //根据被点击按钮的索引处理点击事件  
  85. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {  
  86.     NSLog(@"clickedButtonAtIndex:%d",buttonIndex);  
  87. }  
  88. //AlertView已经消失时  
  89. - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {  
  90.     NSLog(@"didDismissWithButtonIndex");  
  91. }  
  92. //AlertView即将消失时  
  93. - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {  
  94.     NSLog(@"willDismissWithButtonIndex");  
  95. }  
  96.   
  97. - (void)alertViewCancel:(UIAlertView *)alertView {  
  98.     NSLog(@"alertViewCancel");  
  99. }  
  100. //AlertView已经显示时  
  101. - (void)didPresentAlertView:(UIAlertView *)alertView {  
  102.     NSLog(@"didPresentAlertView");  
  103. }  
  104. //AlertView即将显示时  
  105. - (void)willPresentAlertView:(UIAlertView *)alertView {  
  106.     NSLog(@"willPresentAlertView");  
  107. }  
  108. @end
0 0
原创粉丝点击