zoukankan      html  css  js  c++  java
  • IOS提示控件UIActionSheet,UIAlertView

    iphone中常用的消息提示控件,就是UIActionSheet和UIAlertView了,在Web开发中,UIActionSheet就像是confirm(),而UIAlertView就像是alert()一样

    UIActionSheet

    UIAlertView

    但在iphone中,这两个控件的功能可以自定义

    定义两个控件事件方法

    [cpp] view plaincopy
     
    1. #import <UIKit/UIKit.h>  
    2.   
    3. @interface ViewController : UIViewController  
    4. - (IBAction)showActionSheet:(id)sender;  
    5. - (IBAction)showAlertView:(id)sender;  
    6. @end  


    实现事件

    [cpp] view plaincopy
     
    1. - (IBAction)showActionSheet:(id)sender  
    2. {  
    3.     UIActionSheet *showSheet = [[UIActionSheet alloc] initWithTitle:@"提示信息" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:nil];  
    4.     [showSheet showInView:self.view];  
    5.     [showSheet release];  
    6. }  
    7.   
    8. - (IBAction)showAlertView:(id)sender  
    9. {  
    10.     UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示信息" message:@"啊啊" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];  
    11.     [alterView show];  
    12.     [alterView release];  
    13. }  

    UIActionSheet委托代码 ,当点击确认后,弹出UIAlertView窗口提示信息

    [cpp] view plaincopy
     
      1. - (void) actionSheet: (UIActionSheet *) actionSheet  
      2. didDismissWithButtonIndex:(NSInteger)buttonIndex  
      3. {  
      4.     NSString *msg = nil;  
      5.     if (buttonIndex != [actionSheet cancelButtonIndex]) {  
      6.         msg = [NSString stringWithString:@"你选择了确认"];  
      7.     }else {  
      8.         msg = [NSString stringWithString:@"你选择了取消"];  
      9.       
      10.     }  
      11.     UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示信息" message:msg delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];  
      12.     [alter show];  
      13.     [alter release];  
      14.     [msg release];  
      15.       
      16. }  
  • 相关阅读:
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    [技术博客] 使用邮箱验证并激活账户
    OO第一单元作业总结
    OO第一单元总结
    buaaoo_second_assignment
    buaaoo_first_improvement
  • 原文地址:https://www.cnblogs.com/bmate/p/3183361.html
Copyright © 2011-2022 走看看