zoukankan      html  css  js  c++  java
  • UIAlertView和UIActivityIndicatorView的使用

    UIAlertView用来显示一个对话框,可以设置对话框的标题、文案、按钮的个数和文案,也可以通过实现delegate来监听按钮的的点击操作。

    使用UIAlertView时需要注意:

    self.alertView = [[UIAlertView alloc] 
    initWithTitle:@"警告" 
    message:@"警告你,作为男人必须负责,必须努力!" 
    delegate:self 
    cancelButtonTitle:@"取消" 
    //注意:otherButtonTitles可以接收多个字符串作为参数(直到遇到nil终止) otherButtonTitles:@"我是男人",@"我是女人",@"我是小孩", nil];

    UIActivityIndicatorView就是大家耳熟能详的“转菊花”,使用该控件时需要注意:

    1.该控件的高度和宽度无法改变(不同样式的菊花大小也不一样);

    2.调用addSubView之后该控件也是不可见的,除非调用startAnimating

    - (void) btnClicked : (UIButton*) btn {
        int tag = (int)btn.tag;
        if (tag == 101) {
            self.alertView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"警告你,作为男人必须负责,必须努力!" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"我是男人",@"我是女人",@"我是小孩", nil];
     
            [self.alertView show];
        } else if (tag == 102) {
            self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
            self.indicatorView.frame = CGRectMake(100, 100, 80, 80);
            [self.view addSubview:self.indicatorView];
            
            [self.indicatorView startAnimating];
        }
    }
    

      

  • 相关阅读:
    ps图像渐变
    QPaintDevice: Cannot destroy paint device that is being painted
    QWidget::paintEngine: Should no longer be called
    权谋 — 朱元璋
    TL(简单)
    Access“输入的表达式中含有一个无效日期值”
    Qt label加边框
    Guardian of Decency(二分图)
    匈牙利算法的小总结
    Simple Molecules(简单)
  • 原文地址:https://www.cnblogs.com/sunzhenxing19860608/p/5859007.html
Copyright © 2011-2022 走看看