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];
    }

     

  • 相关阅读:
    据说,能找出15个以上的的视力才正常....
    看看用PS来转基因的动物,居然很欢乐!!
    《天引》读书笔记——由新月形面积引发的人类长达2000年的探索。
    练习使用策略模式
    折半查找
    UltraEdit常用配置&搭建Java/C开发环境
    一个操作系统的实现_十分钟完成的操作系统——到这里博客迁移工作圆满结束
    C++中的变量初始化
    LeetCode Range Sum Query
    Peeking Iterator
  • 原文地址:https://www.cnblogs.com/lidongq/p/4064639.html
Copyright © 2011-2022 走看看