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

发表于:2012-06-09 21:21

龙灵絮梦

荣誉:0 问题:2 回复:0

时间: 2024-08-26 14:44:01

得到cell视图的相关文章

xib自定义cell视图出现重叠现象。

今天学习搭建一个团购的界面,自己在敲完代码后视图出现重叠现象 如图所示.检查半天没发现问题.最后对照老师的源代码,找到了问题,原来是自己没有设置单元格的高度代码如下 self.tableView.rowHeight = 80; 加上这句代码之后视图正常.

UICollectionView 集合视图用法,自定义Cell

在View里面 //1.创建UICollectionViewFlowLayout UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init]; //设置 //1.1设置大小 flowLayout.itemSize=CGSizeMake(90, 90); //1.2设置左右间距(注意如果给定间距,无法满足屏幕的宽度,设置无效) flowLayout.minimumInteritemSpacing=

iOS开发>学无止境 - Cell 里的视图控制器

在每个 iOS 开发者的生涯中,总有一些时候想把一个视图控制器放到一个 tableView 的 cell 中.因为这是一个有用的工具去处理我在视图控制器中的各种复杂视图及繁琐操作,而且很容易想象的一种情况是你想要将一些视图堆在另一些视图上面.另一个常见的应用场景是将 collectionView 放在 cell 里.理想情况下里面的 collectionView 拥有它自己的控制器,这样外面的 tableView 控制器不会受到关联视图和每个 collection view cell 数据的影响

表视图控制器(TableViewController)(三) 、 表视图搜索

1 乐库的设置界面 1.1 问题 tableView分为静态(static)和动态(dynamic),之前使用的都是动态的tableView,表视图的有多少分区.有多少行以及每一行显示的内容都不是固定的,都由数据模式来决定.而静态的tableView有多少分区.有多少行以及每一行显示的内容都是固定不变的. 静态tableView应用广泛,常用于各种应用软件的设置界面,本案例使用静态tableView完成乐库的设置界面,如图-1所示: 图-1 1.2 方案 由图-1可以看到该界面的显示内容是固定不

iOS_25_彩票设置的cell的数据源模型的封装

组模型的封装 SettingGroup // // SettingGroup.h // 25_彩票 // // Created by beyond on 14-8-28. // Copyright (c) 2014年 com.beyond. All rights reserved. // 模型,一组(Section,Group),包括 组的header,组的footer,中间的条目(cell数组) #import <Foundation/Foundation.h> @interface Set

IOS 开发指南 第5章 委托协议 数据源协议 高级视图学习

1 委托对象负责控制控件的外观和对控件的事件和状态作出反应 数据源对象是控件与应用数据(model)的桥梁,一般是必须实现的. 2 选择器 UIPickerView 为用户提供选择 1)日期选择器 UIDatePicker 设置属性检查器中的各个属性-代码 -setDateFormat:设置日期格式 -stringFromDate:获取时间 - (IBAction)onclick:(id)sender { NSDate * theDate = self.datePicker.date;获取选中日

UI基础--封装cell滑动时的动画

新建一个类:CellDisplay:NSObject .h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface CellDisplay : NSObject +(void)tableView:(UITableView *)tableView cell:(UITableViewCell *)cell IndexPath:(NSIndexPath *)indexPath; @end .m #impor

不等高cell的搭建(一)

一.界面搭建 1.确定开发模式 如果界面是固定的,可以用xib 界面的一些内容不固定,就用纯代码 cell用什么方式去开发(我们采用纯代码和xib结合的方式) 2.划分层次结构 2.1 怎么划分? 按照功能划分 按照隐藏效果:在某些条件下,一些控件要一起隐藏,就可以放在同一模块中(前提是这些控件集中在一起) 2.2 分析界面发现cell的middleView和commentView不确定要不要显示 所以,cell采用纯代码方法搭建 3.自定义cell 3.1在创建cell的时候,就把所有可能显示

简单tableView的cell的动画旋转

cell 的动画一般用的不多,但是简单的修改一下属性还是能把cell的出场华丽的转世一下,在代理方法willDisplayCell中设置一下layer的属性就OK了. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ //设置anchorPoint    cell.layer.anchorPoi