zoukankan      html  css  js  c++  java
  • UIAlertView & UIActionSheet随笔笔记

    系统UIAlertView在很多地方有使用到,其创建的初始化的方法为:

    - (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... 

    其中title、message 如上图所示;delegate是设置监听对象,通常设为self,也就是ViewController控制器为监听者,并遵循UIAlertViewDelegate协议,可使用协议中的clickedButtonAtIndex设置当点击了按钮后的实现内容;cancelButtonTitle为图中的“取消”,otherButtonTitle为图中的“确定”,按钮可以添加多个,所以...后还可以继续追加;

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

    通过传入的buttonIndex获得用户点击的是哪个button;

    通过alertViewStyle的类型可以设置文本框样式;

    通过textFieldAtIndex:(NSInteger)textFieldIndex获得具体是哪个UITextField;

    最后通过show方法显示UIAlertView;

    UIActionSheet于UIAlertView类似,第一项按钮为红色提示,显示方法不是show而是 showInView.

  • 相关阅读:
    SecureRandom
    《Head First 设计模式》[02] 观察者模式
    《MySQL必知必会》[07] 管理事务处理
    《MySQL必知必会》[06] 触发器
    《MySQL必知必会》[05] 存储过程和游标
    Centos7安装Nginx
    IDEA配置Tomcat
    Java小功能大杂烩
    Java处理中文乱码问题
    Java邮件发送
  • 原文地址:https://www.cnblogs.com/litaowei/p/3712025.html
Copyright © 2011-2022 走看看