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

  

时间: 2025-01-01 01:00:04

UIAlertView和UIActivityIndicatorView的使用的相关文章

iOS UIAlertView中UIActivityindicatorView风火轮提示加载等待

参考:http://stackoverflow.com/questions/18729220/uialertview-addsubview-in-ios7 1.SignInViewController.h #import <UIKit/UIKit.h> @interface SignInViewController : UIViewController<UIAlertViewDelegate>{ UIAlertView *remoteAlertView; } @end 2.Sign

UIAlertView/UIAlertController封装使用

基于UIAlertView封装的JXTAlertView,这个是将之前写Demo时搞的一套快捷使用alertView的工具抽离整理出来的,并提供了C函数直接调用,像这样: jxt_showAlertTitle(@"简易调试使用alert,单按钮,标题默认为"确定""); 就可以直接显示出一个alertView. 基于UIAlertController封装的JXTAlertController,支持iOS8及以上.调用方式为UIViewController的扩展分类方

IOS系统中网络等待的Loading的实现方法 等待加载

镔哥就直接写一个简单的方法吧: 第一种方法: self.title=@"直视行情"; //[self getLodingView]; self.webView =[[UIWebView alloc]initWithFrame:CGRectMake(0, -2, self.view.frame.size.width,self.view.frame.size.height+30)]; [_webView setUserInteractionEnabled:NO]; [_webView se

iOS开发从入门到精通-- 警告对话框UIAlertView和等待提示器UIActivityIndicatorView

警告对话框UIAlertView和等待提示器UIActivityIndicatorView: 1.UIAlertView简单一点就是弹框 2.就是所谓的菊花转圈圈 声明:注意@interface ViewController : UIViewController<UIAlertViewDelegate>这个里面多了一个UIAlertViewDelegate代理 #import <UIKit/UIKit.h> @interface ViewController : UIViewCon

UIAlertView

UIAlertView 1.Title 获取或设置UIAlertView上的标题. 2.Message 获取或设置UIAlertView上的消息 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确

UIAlertView的使用方法

UIAlertView的使用方法 1. 最简单的用法 UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"这是一个简单的警告框!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; [alert release]; 2. 为UIAlertView添加多个按钮 U

IOS开发UI基础 UIAlertView的属性

UIAlertView1.Title获取或设置UIAlertView上的标题. 2.Message获取或设置UIAlertView上的消息 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定&q

UIAlertView 的基本使用方法

?UIAlertView //注意,UIAlertView在9.0后丢弃了,使用UIAlertViewController 1.Title 获取或设置UIAlertView上的标题. 2.Message 获取或设置UIAlertView上的消息 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButt

简述UIAlertView的属性和用法

UIAlertView 1.Title 获取或设置UIAlertView上的标题. 2.Message 获取或设置UIAlertView上的消息 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确