IOS--UIAlertView的使用方法详细

IOS--UIAlertView的使用方法详细

// UIAlertView的常用方法

// 标准样式

UIAlertView *oneAlertView = [[UIAlertView alloc] initWithTitle:@"标题"message:@"提示内容" delegate:self cancelButtonTitle:@"关闭"otherButtonTitles:@"OK", nil];

[oneAlertView show]; // 显示出来

[oneAlertView release], oneAlertView = nil; // 释放内存

oneAlertView.alertViewStyle = UIAlertViewStyleDefault; // 设置oneAlerView的样式

//    UIAlertViewStyleDefault 只弹信息和按钮

//    UIAlertViewStyleSecureTextInput 有一个textfield加密框

//    UIAlertViewStylePlainTextInput 有一个不加密的textfield

//    UIAlertViewStyleLoginAndPasswordInput 有两个textfield,Login和password

// 按钮横排显示

UIAlertView *twoAlertView = [[UIAlertView alloc] initWithTitle:@"标题"message:@"提示内容" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"按钮1", @"按钮2", @"按钮2", nil];

[twoAlertView show]; // 显示出来

[twoAlertView release], twoAlertView = nil; // 释放内存

// 添加了多个按钮,那么要怎么判断我们按下的是哪个按钮呢?

// 需要在.h文件中实现UIAlertViewDelegate代理,然后在.m文件中重写下面的方法

#pragma mark - 实现UIAlertView的代理方法判断按了哪个按钮

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

// 获取您按下的是哪个按钮

NSString* msg = [[NSString alloc] initWithFormat:@"您按下的第%d个按钮!",buttonIndex];

NSLog(@"%@", msg);

[msg release], msg = nil;

// 点击“取消”,“按钮1”,“按钮2”,“按钮3”的索引buttonIndex分别是0,1,2,3

}

// 给UIAlertView添加其他

UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"请等待"

message:nil

delegate:nil

cancelButtonTitle:nil

otherButtonTitles:nil];

[alert show];

UIActivityIndicatorView *activeView = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

activeView.center = CGPointMake(alert.bounds.size.width/2.0f, alert.bounds.size.height-40.0f);

[activeView startAnimating];

[alert addSubview:activeView];

[activeView release];

[alert release];

// 还有很多方法,想深入了解的可以查看api自己慢慢试试。这些基本够用了。。。

时间: 2024-07-29 00:23:15

IOS--UIAlertView的使用方法详细的相关文章

[iOS]数据库第三方框架FMDB详细讲解

[iOS]数据库第三方框架FMDB详细讲解 初识FMDB iOS中原生的SQLite API在进行数据存储的时候,需要使用C语言中的函数,操作比较麻烦.于是,就出现了一系列将SQLite API进行封装的库,例如FMDB.PlausibleDatabase.sqlitepersistentobjects等. FMDB是一款简洁.易用的封装库.因此,在这里推荐使用第三方框架FMDB,它是对libsqlite3框架的封装,用起来的步骤与SQLite使用类似,并且它对于多线程的并发操作进行了处理,所以

iOS手势UIGestureRecognizer识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势) (转)

1.UIGestureRecognizer介绍 手势识别在iOS上非常重要,手势操作移动设备的重要特征,极大的增加了移动设备使用便捷性. iOS系统在3.2以后,为方便开发这使用一些常用的手势,提供了UIGestureRecognizer类.手势识别UIGestureRecognizer类是个抽象类,下面的子类是具体的手势,开发这可以直接使用这些手势识别. UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecog

iOS开发 UITableView的方法和属性总结

本文描述UITableView的各种方法,属性,委托以及数据源.本文的目的只是总结UITableView的用法,详细的例子另撰文描述. 1 数据源  UITableViewDataSource协议 01 返回组(节)的个数,默认是返回1,如果只有1组数据,可以不用实现该方法. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 02 返回某一组的行数,该组由section的值决定 - (NSInteger)table

IOS--UIDatePicker 时间选择器 的使用方法详细

IOS--UIDatePicker 时间选择器 的使用方法详细 // 主要有下面四种类型: // 日期显示. // 日期和时间显示. // 时间显示. // 倒计时选择 // UIDatePicker控件的常用方法  时间选择控件 UIDatePicker *oneDatePicker = [[UIDatePicker alloc] init]; oneDatePicker.frame = CGRectMake(0, 10, 320, 300); // 设置显示的位置和大小 oneDatePic

iOS数据库操作之coredata详细操作步骤

CHENYILONG Blog iOS数据库操作之coredata详细操作步骤 技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http://weibo.com/luohanchenyilong iOS应用数据存取的常用方式 ? XML属性列表 -- PList? NSKeyedArchiver 归档 ?Preference(偏好设置) ? SQLite3? Core DataCore Data简介 ? Core Data 是iOS SDK 里的一个很强大的

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

30多个iOS常用动画,带详细注释

// //  CoreAnimationEffect.h //  CoreAnimationEffect // //  Created by VincentXue on 13-1-19. //  Copyright (c) 2013年 VincentXue. All rights reserved. // #import <Foundation/Foundation.h> /**  !  导入QuartzCore.framework  *  *  Example:  *  *  Step.1

ios系统铃声调用方法

首先,这里我要说明这里并不是真正调用系统内部自带的铃声,因为苹果是不允许开发者调用的,没有给开发者接口:如果调用了就无法上线的!那为什么AppStore里面还有那么多app显示的效果是调用系统的铃声一样呢?为什么就能上线呢?其实不然,他们是使用了系统一样的铃声!也就说他们录制和系统铃声相似,然后包含进他们的bundle中来实现的. 所以,我们想要实现调用系统铃声的效果,只能通过这个途径:把音频文件捆绑经我们的bundle中来调用,播放! 给一个网址,里面好多苹果系统铃声(ios8的也有啦....

UITableView与UIAlertView的 Delegate方法实现

一 UITableView Delegate 方必须遵循 UITableViewDelegate协议 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 这句是定义cell右边的尖角号 #pragma mark - 代理方法 #pragma mark 返回indexPath这行cell的高度 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtInd