zoukankan      html  css  js  c++  java
  • 得到cell视图

    我 使用了dequeueReusableCellWithIdentifier方法为tableview加载cell,然后为cell添加了两个子视图。为 了使dequeueReusableCellWithIdentifier加载的每个cell都是空的,我在 dequeueReusableCellWithIdentifier方法后面添加了移除cell的子视图的方法。现在问题出现了,其中一个子视图恢复正 常,另一个视图却消失了。麻烦大家看一下这是什么问题?相关代码附在下面:

    想实现的效果应该是点击cell出现tmpView_section这个视图,而在cell上左右滑动出现tmpView视图,而现在tmpView_section这个视图消失了

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        //当用户点击cell的时候调用该方法
        NSLog(@"点击cell");
        ifselectedCell = YES;           //设置为YEs表示这个cell被点击
        [tmpView_setIcon setHidden:NO]; //将设置Icon的UIImageView显示出来
        ABPerson *person = [self.PersonArray objectAtIndex:indexPath.row];//得到这一行的人的信息
        selectedRow = indexPath.row;    //
        NSString *name = person.Person_Name;
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];//得到这一行被点击的Cell
        cell.textLabel.text = [NSString stringWithFormat:@"\t\t\t\t\t\t%@\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",name];
        cell.textLabel.font = [UIFont systemFontOfSize:22];
        cell.textLabel.textAlignment = UITextAlignmentLeft;
        cell.textLabel.textColor = [UIColor colorWithRed:0.939 green:0.932 blue:0.930 alpha:1.000];

        [self.tableView reloadData];

       //smallicon-01按钮        
        CustomButton *button_phone = [[CustomButton alloc] initWithFrame:CGRectMake(64, 50, 30, 54) withPerson:person];
        button_phone.tableCell = cell;
        button_phone.tag = 1;
        UIImage *image = [UIImage imageNamed:@"friends.png"];
        [button_phone setImage:image forState:UIControlStateNormal];
        [button_phone addTarget:self action:@selector(setIcon:) forControlEvents:UIControlEventTouchUpInside];
        [tmpView_setIcon addSubview:button_phone];
    //    
        //smallicon-01按钮
        CustomButton *button_message = [[CustomButton alloc] initWithFrame:CGRectMake(128, 50, 30, 54) withPerson:person];
        button_message.tableCell = cell;
        button_message.tag = 2;
        UIImage *image2 = [UIImage imageNamed:@"sweet.png"];
        [button_message setImage:image2 forState:UIControlStateNormal];
        [button_message addTarget:self action:@selector(setIcon:) forControlEvents:UIControlEventTouchUpInside];
        [tmpView_setIcon addSubview:button_message];
    //    
        //smallicon-02按钮
        CustomButton *button_message1 = [[CustomButton alloc] initWithFrame:CGRectMake(192, 50, 30, 54) withPerson:person];
        button_message1.tableCell = cell;
        button_message1.tag = 3;
        UIImage *image3 = [UIImage imageNamed:@"class.png"];
        [button_message1 setImage:image3 forState:UIControlStateNormal];
        [button_message1 addTarget:self action:@selector(setIcon:) forControlEvents:UIControlEventTouchUpInside];
        [tmpView_setIcon addSubview:button_message1];
    //    
    //    //smallicon-03按钮
        CustomButton *button_message3 = [[CustomButton alloc] initWithFrame:CGRectMake(256, 50, 30, 54) withPerson:person];
        button_message3.tableCell = cell;
        button_message3.tag = 3;
        UIImage *image4 = [UIImage imageNamed:@"office.png"];
        [button_message3 setImage:image4 forState:UIControlStateNormal];
        [button_message3 addTarget:self action:@selector(reloadMytableView) forControlEvents:UIControlEventTouchUpInside];
        [tmpView_setIcon addSubview:button_message3];
    //    
        [tmpView setHidden:YES];
    //    
        NSLog(@"这里额图修改了2");
    //    
        tmpView_setIcon.tag = 2;
        [cell addSubview:tmpView_setIcon];
    }

     

  • 相关阅读:
    使用ffmpeg将mp4切片成ts slice 并生成m3u8命令,同时让IIS支持支持 m3u8
    C# 自动下移动光标 。winform 发送tab,在WPF中
    C# 获取当前程序路径方法整理
    Jeecg-Boot 2.0.0 版本发布,基于Springboot+Vue 前后端分离快速开发平台
    vue2.0源码-丰富的选项合并策略
    JavaScript 核心原理精讲
    前端性能优化
    Vue Router模式
    css3实现圆角三角形
    CSS动画
  • 原文地址:https://www.cnblogs.com/lidongq/p/4064639.html
Copyright © 2011-2022 走看看