zoukankan      html  css  js  c++  java
  • 计算器 UITextField

    • 判断UITextField的输入的内容不能为空:(注意:判断UITextField有没有输入字符用字符的length来判断)
      - (IBAction)calculate {
          // 1.拿到用户输入的第一个数字
          NSString *num1String = self.num1Field.text;
          if (num1String.length == 0) {
              
              /*
              UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"输入有误" message:@"第一个输入框不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
              [alertView show];
               */
              [self showError:@"第一个输入框不能为空"];
              
              return;
          }
          
          // 2.拿到用户输入的第二个数字
          NSString *num2String = self.num2Field.text;
          if (num2String.length == 0) {
              
              /*
              UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"输入有误" message:@"第二个输入框不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
              [alertView show];
               */
              [self showError:@"第二个输入框不能为空"];
              
              return;
          }

      3.展示信息的错误方法

    • 1 // 展示错误信息
      2 - (void)showError:(NSString *)error
      3 {
      4     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"输入有误" message:error delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
      5     [alertView show];
      6 }
  • 相关阅读:
    ECshop 二次开发模板教程4
    ECshop 二次开发模板教程3
    ECshop 二次开发模板教程2
    ECshop 二次开发模板教程1
    ecshop 二次开发及模板标签
    ECSHOP seo修改建议
    Ecshop ajax 局部刷新购物车功能
    ECSHOP
    echo二次开发 ecshop 函数列表
    Ecshop文件结构,二次开发
  • 原文地址:https://www.cnblogs.com/mshong1616/p/5095407.html
Copyright © 2011-2022 走看看