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.询问还有一个解决 ...
随机推荐
- UVA 12904 Load Balancing 暴力
Load Balancing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/vi ...
- OutputDebugString()
坚定的 Win32 开发者可能对 OutputDebugString() API 函数比較熟悉,它能够使你的程序和调试器进行交谈.它要比创建日志文件easy,并且全部“真正的”调试器都能使用它.应用程 ...
- [MEAN Stack] First API -- 1. with Node.js, Express and MongoDB
Learn how to import data into your MongoDB and then use Express to serve a simple Node.js API. Impor ...
- android 自定义ViewGroup和对view进行切图动画实现滑动菜单SlidingMenu
示意图就不展示了,和上一节的一样,滑动菜单SlidingMenu效果如何大家都比较熟悉,在这里我简单说明一下用自定义ViewGroup来实现. 实现方法:我们自定义一个ViewGroup实现左右滑动, ...
- 你真的了解javascript吗
原文地址:http://dmitry.baranovskiy.com/post/91403200 看了文章中五个小例子,写了写自己的理解 #demo1 if (!("a" in w ...
- 给指针malloc分配空间后就等于数组吗?
首先回答这个的问题:严格的说不等于数组,但是可以认为它是个数组一样的使用而不产生任何问题.不过既然这样,那它应该算是个数组吧.所以,一般我们都用“动态数组”这种名字来称呼这种东西. 要讲清楚这个东西, ...
- Android消息机制——时钟显示和异步处理工具类(AsyncTask)
1. 时钟显示 定义布局文件——activity_my_analog_clock_thread_demo.xml <?xml version="1.0" encoding=& ...
- spring框架七大模块
1. Spring Core: Core封装包是框架的最基础部分,提供IOC和依赖注入特性.这里的基础概念是BeanFactory,它提供对Factory模式的经典实现来消除对程序性单例模式的需要,并 ...
- c#使用MethodInvoker解决跨线程访问控件
功能函数测试集锦(77) C#专区(114) 版权声明:本文为博主原创文章,未经博主允许不得转载. .net 原则上禁止跨线程访问控件,因为这样可能造成错误的发生,有一种方法是禁止编译器对跨线 ...
- Ubuntu下安装FTP服务及使用(VSFTPD详细设置)(二)
vsftpd 作为一个主打安全的FTP服务器,有很多的选项设置.下面介绍了vsftpd的配置文件列表,而所有的配置都是基于vsftpd.conf这个配置文件 的.本文将提供完整的vsftpd.conf ...