警示框
来源:互联网 发布:北京哪里体检最好 知乎 编辑:程序博客网 时间:2024/04/27 14:35
1、UIActionSheet创建一个简单动作表,
UIActionSheet *actionSheet = [[UIActionSheetalloc]initWithTitle:@"Choose action"
delegate:nilcancelButtonTitle:nildestructiveButtonTitle:nilotherButtonTitles:nil];//基本的初始化、代理设置、按钮的设置
//初始化的时候也可以增加多个按钮
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose action"
delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@“1”,@"2",@“3”,@"4"];
//基本的初始化、代理设置、按钮的设置
2、增加按钮的方法
[actionSheet addButtonWithTitle:@"Take picture"];
[actionSheet addButtonWithTitle:@"Choose picture"];
[actionSheet addButtonWithTitle:@"Take video"];
[actionSheet addButtonWithTitle:@"Cancel"];//增加按钮
//set the desctructiveButtonIndex to the button that is responsible for the cancel function
3、设置按钮索引的数字
actionSheet.destructiveButtonIndex=3;//
[actionSheet showInView:self.view];// 注意这里显示方法和alertView的区别
4、显示ActtionSheet的方法
- (void)showFromToolbar:(UIToolbar *)view;
- (void)showFromTabBar:(UITabBar *)view
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animatedNS_AVAILABLE_IOS(3_2);
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animatedNS_AVAILABLE_IOS(3_2);//在指定的区域内显示
//会有这些方法就是因为显示的时候并不一定要选择,而下面的方法一定要选择一个,因为他是在view界面,会成为第一xia响应者,而上面的不会成为第一响应者。
- (void)showInView:(UIView *)view;
@interface YDViewController ()<UIActionSheetDelegate>
点击了之后调用的代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
int index = buttonIndex;
[actionSheet dismissWithClickedButtonIndex:buttonIndexanimated:YES];//这个方法调用就会解散这个actionSheet,并且在索引上使用开关来识别用户做何种选择。
//不过经过测试,好像这句话没有起到作用?????
switch (index) {
case0:
{
NSLog(@"Take picture selected");
}
break;
case1:
{
NSLog(@"Choose picture selected");
}
break;
case2:
{
NSLog(@"Take video selected");
}
break;
case3:
{
NSLog(@"Cancel selected");
}
break;
default:
break;
}
}
上面的方法就是点击上面的按钮之后就会调用到这个方法,通过按钮的索引来区别不同的按钮。UIalertView这里的UIalertView是通过相关的alert样式来显示。
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case0:
{
//NO Selection or single button action
}
break;
case1:
{//OK
}
break;
default:
break;
}
//to access the UITextFields you can use
if (alertView.alertViewStyle ==UIAlertViewStylePlainTextInput)
{
UITextField* username = [alertViewtextFieldAtIndex:0];
//use the username instance
}
elseif (alertView.alertViewStyle ==UIAlertViewStyleSecureTextInput)
{
UITextField* password = [alertViewtextFieldAtIndex:0];
//use the password instance
}
else if (alertView.alertViewStyle ==UIAlertViewStyleLoginAndPasswordInput)
{
UITextField* username = [alertViewtextFieldAtIndex:0];
UITextField* password = [alertViewtextFieldAtIndex:1];
//use the username and password instance
}
}
- 警示框
- 警示框
- bootstrap警示框
- Bootstrap 警示框
- Android-AlertView(警示框)
- 警示
- 警示!!!!!!!
- 警示
- 警示!!
- 警示。
- 警示
- 仿安卓 警示框 悬浮框
- 警示框+输入框+确认框
- 创建CSS3警示框渐变动画
- iOS个人整理17-警示框--UIAlertController
- 自定义延时消失的警示框
- 统一iOS里的警示框
- AlertDialog可以创建任何你想要的警示框
- Spring 注解学习——@ResponseBody,@RequestBody,@PathVariable
- Scala中链式调用
- POJ 3468
- 工具类分享--便捷地改变字体样式
- Android开发之onClick事件的4种写法
- 警示框
- JAVA算法习题
- Python下opencv使用笔记(八)(图像金字塔)
- HTML 4.01、XHTML 1.0 Strict和Transitional 的区别
- 【PAT】1034. 有理数四则运算(20)
- Android Studio 报错: Failed to complete Gradle execution
- 玩命牛的成长记录(二十四)——渐变
- Node:最小堆
- AOS V0.2 发布,JavaEE 应用基础平台