UIAlertView和UIActivityIndicatorView的使用

UIAlertView用来显示一个对话框,能够设置对话框的标题、文案、按钮的个数和文案,也能够经过实现delegate来监听按钮的的点击操做。blog

使用UIAlertView时须要注意:字符串

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

UIActivityIndicatorView就是你们耳熟能详的“转菊花”,使用该控件时须要注意:it

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

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

 

- (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];
    }
}
相关文章
相关标签/搜索