UIAlertView[警告框] [代理协议型]UIActionSheet [表单视图][代理协议型]
//
// ViewController.h
// UIAlertViewAndUIActionSheet
//
// Created by hehe on 15/9/21.
// Copyright (c) 2015年 wang.hehe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelegate>
@end
//
// ViewController.m
// UIAlertViewAndUIActionSheet
//
// Created by hehe on 15/9/21.
// Copyright (c) 2015年 wang.hehe. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self creatButton];
}
#pragma mark ----------------------创建一个button
- (void)creatButton
{
UIButton *alertButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 100, 60, 30)];
[self.view addSubview:alertButton];
alertButton.backgroundColor = [UIColor grayColor];
[alertButton setTitle:@"弹出警告框" forState:UIControlStateNormal];
[alertButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
alertButton.titleLabel.adjustsFontSizeToFitWidth = YES;
[alertButton addTarget:self action:@selector(showAlert) forControlEvents:UIControlEventTouchUpInside];
//*******************************************
UIButton *actionBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 200, 200, 30)];
[self.view addSubview:actionBtn];
actionBtn.backgroundColor = [UIColor grayColor];
[actionBtn setTitle:@"弹出表单" forState:UIControlStateNormal];
[actionBtn setTitleColor:[UIColor redColor] forState:0];
actionBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
[actionBtn addTarget:self action:@selector(showActionSheet) forControlEvents:UIControlEventTouchUpInside];
}
- (void)showActionSheet
{
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"你确定要删除?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"删除" otherButtonTitles:@"确定", nil];
[as showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"10");
//当button 押下的时候调用
NSLog(@"index = %ld",buttonIndex);
}
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{
NSLog(@"11");
}
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
NSLog(@"12");
}
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet
{
NSLog(@"13");
}//
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"14");
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"15");
}
////////////////////////////////////////////////////
- (void)showAlert
{
//[注]不需要添加到父视图,不需要设定坐标
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"警告" message:@"输入的密码错误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", @"ok",nil];
[av show];
av.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
av.tag =10;
}
#pragma mark ------------------------alert view delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//当button 押下的时候调用
NSLog(@"index = %ld",buttonIndex);
}
- (void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"will present");
}
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
UITextField *tf = [alertView textFieldAtIndex:0];
if([tf.text isEqualToString:@"123"])
return YES;
else
return NO;
}
- (void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"0");
}
// after animation
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"1");
}
// before animation and hiding view
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"2");
}
// after animation
@end
UIAlertView[警告框] [代理协议型]UIActionSheet [表单视图][代理协议型]的更多相关文章
- IOS UIAlertView(警告框)方法总结
转自:my.oschina.net/u/2340880/blog/408873?p=1 IOS中UIAlertView(警告框)常用方法总结 一.初始化方法 - (instancetype)initW ...
- IOS中UIAlertView(警告框)常用方法总结
一.初始化方法 - (instancetype)initWithTitle:(NSString *)title message:(NSString*)message delegate:(id /*&l ...
- Bootstrap-Plugin:警告框(Alert)插件
ylbtech-Bootstrap-Plugin:警告框(Alert)插件 1.返回顶部 1. Bootstrap 警告框(Alert)插件 警告框(Alert)消息大多是用来向终端用户显示诸如警告或 ...
- Jquery学习笔记:操作form表单元素之一(文本框和下拉框)
一.概述 在web页面开发中,经常需要获取和设置表单元素的值(如文本框中的内容),特别是在ajax应用中,更是常态.本文系统的介绍下如何操作. 同操作其它html元素一样,操作的过程差不多. 第一步, ...
- JS的文本框验证以及form表单的提交阻止
js: 1.只能输入数字 只能输入数字:<input type="text" onkeyup="javascript:ReNumber(this)" /& ...
- 前端笔记:React的form表单全部置空或者某个操作框置空的做法
1.全部置空的做法,一般在弹出框关闭后,需要重置该form所有表单: this.props.form.resetFields(); 2.针对某个操作框置空的做法 例如,form表单里有一个部门和一个张 ...
- IOS 警告框 (UIAlertView)的使用方法
1.普通警告框 IOS的SDK中提供了一个方便的类库UIAlertView,配合着不同参数来使用此类可以做出大多数的警告框,如下代码是IOS最简单的警告框. UIAlertView *alert = ...
- iOS:提示框(警告框)控件UIAlertView的详解
提示框(警告框)控件:UIAlertView 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能. 类型:typedef NS_ENUM(NSInte ...
- 警告框和操作表(IOS开发)
警告框(AlertView)时模态的,不关闭它就不能做其它事情,所以不是下面几种情况不应该随便使用. 1.应用不能继续执行. 如内存不足,没有网络.一般仅仅须要一个button. 2.询问还有一个解决 ...
随机推荐
- C# 程序员最常犯的 10 个错误
关于C# C#是达成微软公共语言运行库(CLR)的少数语言中的一种.达成CLR的语言可以受益于其带来的特性,如跨语言集成.异常处理.安全性增强.部件组合的简易模型以及调试和分析服务.作为现代的CLR语 ...
- Android开发 Unity3D基础 Android Development
开发环境 Window 7 Unity3D 3.3.0 MB525 defy Android 2.1-update1 本次学习: 1.认识Unity 2.Unity3D环境搭建与Android软件生成 ...
- [原创]-CMD命令设置IP地址
问题描述 在实际工作中,尤其是像我们这种BI分析人员,在做项目的时候,时常都需要因客户的不同随时切换不同的网络环境,有时可能需要在公司和客户之间来回的穿梭.交替.问题也就随之而来:每次客户那里都需要设 ...
- Dapper链接查询扩展
一对多映射关系 /// <summary> /// 一对多连接查询 /// </summary> /// <typeparam name="FirstT&quo ...
- php模拟多线程
一:应该知道的: php本身是不支持多线, 但是php的好搭档,apache和linux是支持的,故lamp才是最佳组合,还在使用win服务器的现在知道为什么要用linux吧.既然是模拟的, 就不是真 ...
- 解决vim中鼠标右键无法复制的问题
转:http://www.cnblogs.com/jianyungsun/archive/2011/03/19/1988855.html 这是我的vim配置文件:jeffy-vim-v2.4.tar ...
- Linux下mv命令详解
mv命令格式:mv [选项] 源文件或目录 目标文件或目录 mv命令参数(选项): -b :若需覆盖文件,则覆盖前先行备份. -f :force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖: ...
- 源码-hadoop1.1.0-core-org.apache.hadoop
按包的顺序类的顺序来吧,因为我不懂hadoop类的具体体系和类之间的联系,如果有一定知识积累的可以看下别人写的hadoop源码解读类的书,类似的有 http://pan.baidu.com/s/1i3 ...
- 浅析jQuery中常用的元素查找方法总结
本篇文章是对jQuery中常用的元素查找方法进行了详细的总结和介绍,需要的朋友参考下 $("#myELement") 选择id值等于myElement的元素,id值不能重复在文 ...
- cplusplus系列>algorithm>std::for_each
http://www.cplusplus.com/reference/algorithm/for_each/ 对一个序列应用函数.可以是函数指针,或者是functor. // for_each exa ...