Tag: 自定义单元格

如何实现自定义单元格

我正在尝试改变tableview从generics到自定义的单元格,并创build了一个新的tableview单元格类。 但是,我无法让单元格识别新的自定义单元格。 相反,它仍然显示通用单元格,虽然我已经在识别检查器中将故事板中的设置更改为自定义,并且还将tableview单元格的类更改为新的自定义单元格。 我还将故事板中单元格中的元素连接到新的自定义类。 我的理解是tableview VC知道从tableView cellForRowAtIndexPath方法使用哪个类,我也改变了下面的代码。 该项目编译,但继续显示旧的通用单元格。 任何人都可以看到错误或build议还有什么要做? #import "customCell.h" – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { customCell *cell = (customCell *)[self.tableView dequeueReusableCellWithIdentifier:@"Cell"]; Items *item = [self.fetchedResultsController objectAtIndexPath:indexPath]; return cell; } 在此先感谢您的任何build议。 编辑: 自定义单元格通过拖动元素在桌面视图顶部的故事板中创build。 也许这是问题: 单元格样式设置为自定义:

在另一个类中创build一个函数

我试图通过使用我的视图控制器中的函数在我的自定义tableViewCell类中引发一个函数。 我对如何做到这一点真的很无知,所以我试着写这样的: TableViewCell.timerStarted() 我试图摆脱的function看起来像这样: func timerStarted(){ timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update", userInfo: nil, repeats: true) } 其中TableViewCell是我的类的名称和timerStarted函数的名称。 这给我一个错误,说它错过了括号内的一个参数。 我很困难,任何build议,将不胜感激。

cachingtableView单元格数据

在我的应用程序中,我使用URL下载一些图像,并将它们放在cell.imageView[indexPath.row] (这是一个带有cell.imageView[indexPath.row]的自定义单元格)。 我一次可以看到两个单元格,并且注意到了这个方法 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> CustomCell { } 每当单元格被显示时都会调用它。 所以我的应用程序继续下载从服务器的图像和应用程序结果非常缓慢。 我想知道是否有可能caching我已经看到的细胞的数据,所以我不需要重新下载图像,如果我在我的tableView向上滚动! 代码说话我只想调用上面写的func只有当我向下滚动表格,而不是我已经看到的单元格。

禁用所选单元格的prepareForReuse

我有一个自定义的UITableViewCell 。 当一个单元格被选中时,一个UILabel被添加到它。 我不得不使用prepareForReuse来避免混乱,就像这样: – (void)prepareForReuse { NSArray *viewsToRemove = [self.view subviews]; for (UILablel *label in viewsToRemove) { [label removeFromSuperview]; } } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CategorieCell *customCell = [tableView dequeueReusableCellWithIdentifier:@"cellID" forIndexPath:indexPath]; return customCell; } 问题是当我向下滚动标签不在视图中,然后向后滚动,标签就不存在了。 原因很明显,因为当单元格被重用时,我删除了所有的标签。 那么是否有一种方法可以禁用所选行的prepareForReuse (或只是方法中的代码),以及如何?

不能更改自定义UITableViewCell中的透明BG(分组表视图)

有许多关于UITableViews(分组和普通)的单元格背景(自定义或标准)的问题,但是我没有发现这个特定的问题。 基本上我有一个分组风格的UITableView。 问题:我无法让我的自定义单元格具有透明背景以外的任何东西。 这是我的表格看起来像我实现我的自定义单元格之前(即这只是一个普通的分组表格视图): 标准,正常分组桌面。 大。 但是我想要自定义单元格。 所以我build立了一个如下所示的自定义单元格: 有了这个层次: 和这个单元格的背景元数据: 不幸的是,无论我做什么,无论是将背景变为白色,清晰还是黑色,都没有什么不同,我的桌面视图仍然是这样的: (这是表视图的背景,fwiw,即现在这些单元格是透明的)。 而且,当然,我不能通过改变添加到单元格中的视图的背景来解决这个问题,因为那么所有的东西看起来就像这样(注意没有圆angular等等): 这显然是丑陋的,不可接受的。 如何使单元格具有像标准默认单元格一样的普通白色背景? 奇怪的是,上周我的一个应用程序做了一个自定义的单元格完全相同的程序,那些背景出来白色就好了。 我在这里错过了什么? 我所需要的是我的自定义单元格具有符合分组表格视图的弯曲顶部和底部angular落的白色背景。 我在其他实现中已经看到了白色的背景,所以我知道它可以用一个自定义的单元格。 但有些东西在这里不起作用! 我很高兴发布任何代码,只是不知道什么是需要/想要的。 这是我的cellForRowAtIndexPath方法(这只是tableView的核心数据版本:cellForRowAtIndexPath :): – (UITableViewCell *)tableView:(UITableView *)tableView cellForManagedObject:(NSManagedObject *)managedObject { static NSString *ReuseIdentifier = @"customSummaryCell"; CustomSummaryTableViewCell *cell = (CustomSummaryTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ReuseIdentifier]; if (cell == nil) { NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomSummaryTableViewCell" owner:nil options:nil]; for […]

UITableview中的多个切断单元格

任何人都可以给我想法如何在一个UITableView中定义两个自定义单元格? 一个单元应该只包含文本,而另一个包含video或图像。 高度也彼此不同。 我需要像下面给出的图像一样的单元格 – 这是我正在开发的代码, – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier1 = @"tablecell"; static NSString *CellIdentifier2 = @"tablecell1"; if ([self.arrayAction isEqual:@"follow"]) { ActivityFeedCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; [utilities roundedLayer:cell.sub_view.layer shadow:YES]; [utilities AddBorder:cell.updated_imgView]; cell.userName_label.text=[[[[[[_responseArray valueForKey:@"name"]objectAtIndex:indexPath.row]stringByAppendingString:@" "]stringByAppendingString:@"("]stringByAppendingString:[[_responseArray valueForKey:@"age"]objectAtIndex:indexPath.row]]stringByAppendingString:@")"]; cell.descriptionImg_label.text=[[_responseArray valueForKey:@"description"]objectAtIndex:indexPath.row]; NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://tattoosingles.net/tattoouploads/%@",[_arrayname objectAtIndex:indexPath.row]]]; [cell.updated_imgView sd_setImageWithURL:url]; [utilities […]

无法更改所选定制单元格中的图像

我创build了一个自定义的单元格来显示文本和2个图像,当用户select单元格时,图像应该改变。 我可以访问单元格的属性,但不能更改它们: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; CustomCell *cell = (CustomCell *)[self.tableView cellForRowAtIndexPath:indexPath]; cell.check.image = setImage:[UIImage imageNamed:@"1355327732_checkbox-checked"]; [cell.check setImage:[UIImage imageNamed:@"1355327732_checkbox-checked"]]; } cell.check是一个UIImageView 我错过了什么?

显示复选标记附件视图移动表格内容

我跟着苹果的文档在这里添加子视图到UITableViewcell 给单元格添加第三个标签。 问题是当我显示右侧的标准复选标记附件视图时,即使没有显示第三个标签,整个单元格内容也会左移。 下面的截图 。 这是我的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"MyCell"; UILabel *mainLabel, *secondLabel, *thirdLabel; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; //cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; cell.accessoryType = UITableViewCellAccessoryNone; mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 2.0, 100.0, 21.0)]; mainLabel.tag = MAINLABEL_TAG; […]

我如何绘制多列UITableView?

我想绘制一个多列UITableView,如下面的图片,这是不同于一个普通的自定义单元格。 我该怎么做呢?

UITableViewCell中。 如何在触摸时突出显示单元格?

我有一个自定义tableViewCell。 我想通过突出显示用户触摸。 单元格select样式是UITableViewCellSelectionStyleBlue 。 在父控制器中,我设置了self.clearsSelectionOnViewWillAppear = YES 。 我应该很好去。 不。 select仍然坚持细胞。 我想要的只是在接触的时间内select指示。 触摸时应立即返回未选定的外观。 我该怎么做呢? 干杯, 道格