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

  • 相关阅读:
    scrapy 中间件
    索引
    理解平均负载
    jquery1
    网络编程
    模块
    进程
    图书管理系统用ajax删除书籍
    mysql
    jquery
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3095463.html
Copyright © 2011-2022 走看看