//
//  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 [表单视图][代理协议型]的更多相关文章

  1. IOS UIAlertView(警告框)方法总结

    转自:my.oschina.net/u/2340880/blog/408873?p=1 IOS中UIAlertView(警告框)常用方法总结 一.初始化方法 - (instancetype)initW ...

  2. IOS中UIAlertView(警告框)常用方法总结

    一.初始化方法 - (instancetype)initWithTitle:(NSString *)title message:(NSString*)message delegate:(id /*&l ...

  3. Bootstrap-Plugin:警告框(Alert)插件

    ylbtech-Bootstrap-Plugin:警告框(Alert)插件 1.返回顶部 1. Bootstrap 警告框(Alert)插件 警告框(Alert)消息大多是用来向终端用户显示诸如警告或 ...

  4. Jquery学习笔记:操作form表单元素之一(文本框和下拉框)

    一.概述 在web页面开发中,经常需要获取和设置表单元素的值(如文本框中的内容),特别是在ajax应用中,更是常态.本文系统的介绍下如何操作. 同操作其它html元素一样,操作的过程差不多. 第一步, ...

  5. JS的文本框验证以及form表单的提交阻止

    js: 1.只能输入数字 只能输入数字:<input type="text" onkeyup="javascript:ReNumber(this)" /& ...

  6. 前端笔记:React的form表单全部置空或者某个操作框置空的做法

    1.全部置空的做法,一般在弹出框关闭后,需要重置该form所有表单: this.props.form.resetFields(); 2.针对某个操作框置空的做法 例如,form表单里有一个部门和一个张 ...

  7. IOS 警告框 (UIAlertView)的使用方法

    1.普通警告框 IOS的SDK中提供了一个方便的类库UIAlertView,配合着不同参数来使用此类可以做出大多数的警告框,如下代码是IOS最简单的警告框. UIAlertView *alert = ...

  8. iOS:提示框(警告框)控件UIAlertView的详解

    提示框(警告框)控件:UIAlertView   功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.   类型:typedef NS_ENUM(NSInte ...

  9. 警告框和操作表(IOS开发)

    警告框(AlertView)时模态的,不关闭它就不能做其它事情,所以不是下面几种情况不应该随便使用. 1.应用不能继续执行. 如内存不足,没有网络.一般仅仅须要一个button. 2.询问还有一个解决 ...

随机推荐

  1. cocos2dx的图片载入

    //data: 图片文件数据 dataLen: 文件长度 bool Image::initWithImageData(const unsigned char * data, ssize_t dataL ...

  2. 设计模式 ( 十八 ) 策略模式Strategy(对象行为型)

    设计模式 ( 十八 ) 策略模式Strategy(对象行为型) 1.概述 在软件开发中也经常遇到类似的情况,实现某一个功能有多种算法或者策略,我们能够依据环境或者条件的不同选择不同的算法或者策略来完毕 ...

  3. cxx-generator JS绑定工具

    第一部分:配置安装环境 cxx-generator是由Zynga工程师贡献的C++代码绑定到js工具.用于将cocos2d-x 的c++代码,生成相应的js绑定代码(由c++写成),然后将这些函数注册 ...

  4. 剑指 offer set 5 二进制中 1 的个数

    总结 1. 负数右移会保持其符号. 比如 0x80000000 右移, 其对应的绝对值也是 0X80000000, 其右移一位并保持符号, 得到 0XC0000000. 符号位保持, 使得负数永远都无 ...

  5. 15+ tar command usages with examples – Unix/Linux--reference

    reference :http://crybit.com/tar-command-usages-with-examples/ The ‘tar’ saves many files together i ...

  6. chrome打不开12306

    chrome打不开12306怎么办?chrome怎么会打不开12306? chrome打不开12306: 1.没有安装12306网站的根证书. 2.打开https://dynamic.12306.cn ...

  7. 学java入门到精通,不得不看的15本书

    学java入门到精通,不得不看的15本书 一.Java编程入门类1.<Java编程思想>2.<Agile Java>中文版 二.Java编程进阶类1.<重构 改善既有代码 ...

  8. SpringMVC上传(通过物理路径)

    内容来源:http://blog.csdn.net/kouwoo/article/details/40507565 一.配置文件:SpringMVC 用的是 的MultipartFile来进行文件上传 ...

  9. solrj-solr Guide 4.7

    solrj是一个很容易使java应用程序和solr进行交互的一个API,solrj隐藏了很多连接Solr的细节,允许你的应用程序使用简单的高级方法和solr互动交流. solrj的核心就是 org.a ...

  10. Java基础知识强化之IO流笔记82:NIO之 Pipe(管道)

    1. Java NIO 管道是2个线程之间的单向数据连接.Pipe有一个source通道和一个sink通道.数据会被写到sink通道,从source通道读取. 这里是Pipe原理的图示: 2. Pip ...