zoukankan      html  css  js  c++  java
  • 利用UIAlertView的TextInput,把信息输入到UItableViewCell得detailstext里。

    alertView可以标记自己textView的index,通过index调用。

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {

        [tableView deselectRowAtIndexPath:indexPath animated:NO];

        

        if (indexPath.section == 0)

        {

            UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:@"相册"otherButtonTitles:@"拍照",nil];

            [actionSheet showInView:self.view];

            actionSheet.destructiveButtonIndex = 0;

        }

        else if (indexPath.section == 1)

        {

            

            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

            

            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"输入新名字" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

            alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

            

            [alertView show];

            

            

            //得到输入框

            UITextField *tf=[alertView textFieldAtIndex:0];

            tf.placeholder = cell.detailTextLabel.text;

        }

    }

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

    {

        if (buttonIndex == 1)

        {

            //得到输入框

            UITextField *tf=[alertView textFieldAtIndex:0];

            

            if ([tf.text trimWhitespace].length <= 0)

            {

                [MTHint toast:@"不能为空" toView:self.view displaytime:2.0f];

                

                return;

            }

            

            if (![self isValidateUser:tf.text])

            {

                [MTHint toast:@"姓名只能由中文、字母或数字组成" toView:self.view displaytime:2.0f];

                

                return;

            }

            

            if (tf.text.length >= 10)

            {

                [MTHint toast:@"姓名需少于10个字符" toView:self.view displaytime:2];

                

                return;

            }

            

            [titleValues replaceObjectAtIndex:1 withObject:tf.text];

            [_tableView reloadData];

        }

     

    }

  • 相关阅读:
    mybatis中 无效的比较: invalid comparison: java.util.Date and java.lang.String
    java中日期的加减,比较,以及与String的互相转换
    Java中文件上传下载 --使用Minio
    Dubbo SPI 源码深入分析
    新建Maven项目 发布服务 注册到zookeeper
    Dubbo SPI 源码分析
    思维方法
    JDK 和 Dubbo SPI 的入门浅析Demo
    Dubbo不用注册中心实现远程调用的简单用法demo
    解决linux系统下tar解压文件报错问题
  • 原文地址:https://www.cnblogs.com/rankilau/p/4146986.html
Copyright © 2011-2022 走看看