zoukankan      html  css  js  c++  java
  • nullnullIOS控件AlertView的使用

    时间紧张,先记一笔,后续优化与完善。

        

        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
            }
        }
    }
    
    

    Additional References

        

        

        

    文章结束给大家分享下程序员的一些笑话语录: 看新闻说中国输入法全球第一!领先了又如何?西方文字根本不需要输入法。一点可比性都没有。

    --------------------------------- 原创文章 By null和null ---------------------------------

  • 相关阅读:
    centos出现“FirewallD is not running”怎么办
    百度编辑器(Ueditor)最新版(1.4.3.3)插入锚点失败原因分析及BUG修复
    centos rm -rf 恢复删除的文件
    php实现粘贴截图并完成上传功能
    微信网页授权java实现
    JAVA使用POI读取EXCEL文件的简单model
    java读取excel文件数据
    java文件操作(读流)
    oracle 10g正则表达式 REGEXP_LIKE 用法
    Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3095463.html
Copyright © 2011-2022 走看看