滚动更多时间时UiTbleview单元重叠

编程入门 行业动态 更新时间:2024-10-23 11:25:49
本文介绍了滚动更多时间时UiTbleview单元重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 UITableView 在视图中显示不同的数据.我正在使用由.m文件中的代码创建的 UITableViewCell .它们总共是9种不同类型的单元格,其单元格的高度和标识符为0.当表格中具有两个不同高度的同一单元格开始相互重叠.

I am using UITableView for displaying different data in the view. I am using UITableViewCell created by code in the .m file. Their are total 9 different kind of cell with 0 different identifiers and heights for the cell. when the same cell with two different heights in the table it start overlapping each other.

在这里,我将代码放到单元格方法的高度.

Here I am putting the code for the height of the cell method.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row ==0) { return 120.0; } else{ //For Action User follow if(condition) { //Checking if the Follow is shared or not if() { //Checking the number of Counts if() { if() { if() { return 340.0+(arTemp1.count*50.0); } else { return 157.0+(arTemp1.count*50.0); } } else { if() { return 340.0+200; } else { return 157.0+200; } } } else { if( ) { return 340.0f; } else{ return 157.0f; } } } else { if(arTemp1.count>0) { if(arTemp1.count <4) { if() { height=height+150; } return height+(arTemp1.count*50.0); } else { if( ) { height= height; } return height; } } else { if() { height= height+40; } return height; } } } else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 160.0+(arTemp1.count*50.0); } else { return 160.0+200; } } else { return 150.0f; } } //For Action Add New Reciepe else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 420.0+(arTemp1.count*50.0); } else { return 420.0+200; } } else { return 400.0f; } } else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 350.0+(arTemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } //For Action Added new page else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 350.0+(arTemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 170.0+(arTemp1.count*50.0); } else { return 150.0+200; } } else { return 150.0f; } } //For Action Add Photo else if () { if(arTemp1.count>0) { if(arTemp1.count <4) { return 350.0+(arTemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } } return 0.0f; }

行代码单元格

NSString *CellIdentifier = @"a"; UITableViewCell *a = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (a == nil) { //Follow Cell Initializing a = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; a.selectionStyle = UITableViewCellSelectionStyleNone; a.tag=a; //Create Cell Method [self aCreateCell:a atIndexPath:indexPath]; } // Set Cell Method [self aSetCell:a atIndexPath:indexPath]; [a setClipsToBounds:YES]; return a;

推荐答案

尝试一下

首先,您要使用tableView注册单元格类

First you register your cell class with tableView

- (void)viewDidLoad{ /*IF You are using class */ [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellIdentifire"]; /* if you are using nib */ // LOAD UP THE NIB FILE FOR THE CELL UINib *nib = [UINib nibWithNibName:@"CustomNibCell" bundle:nil]; // REGISTER THE NIB FOR THE CELL WITH THE TABLE [self.tableView registerNib:nib forCellWithReuseIdentifier:@"cellIdentifire"]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifire" forIndexPath:indexPath]; /* Write code cell.title= @"hello"; */ return cell; }

更多推荐

滚动更多时间时UiTbleview单元重叠

本文发布于:2023-11-26 20:09:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元   时间   更多   UiTbleview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!