Tag: uitableviewautomaticdimension

UITableViewAutomaticDimension单元格滚动或拉动刷新后resize

我添加了一个表格视图,我在单元格中显示图像。 我也添加了这个代码: tableView.estimatedRowHeight = 175 tableView.rowHeight = UITableViewAutomaticDimension 这样细胞的大小取决于图像。 当我启动我的应用程序,但我得到这个: 和图像不加载,直到我开始滚动…如果我向下滚动一半的页面,然后回到顶部,我得到这个(这是正确的): 此外,如果我删除像button,只有在一个单元格中的图像,当我启动我的应用程序,如果我等待3秒,而不触及任何细胞resize,他们自己..?! 有任何想法吗? 我已经研究了谷歌和尝试旧版本的Xcode的奇怪的解决scheme,但似乎没有工作! 这里是我的TableViewController的代码的其余部分: extension TimelineViewController: UITableViewDataSource { func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 46 } func numberOfSectionsInTableView(tableView: UITableView) -> Int { return timelineComponent.content.count } func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let headerCell = tableView.dequeueReusableCellWithIdentifier("PostHeader") as! PostHeaderTableViewCell […]

在UITableViewCell中加载UIView的Nib文件不能拉伸

我有一个可以通过nib / xib文件重用的UIView。 我想加载这个,并填写一个UITableViewCell这是一个自我调整UITableView中使用。 所有与自动布局。 大多数工程很好,但似乎加载UIView使用附加的约束,缩小UITableViewCell的contentView。 这对身高是有好处的,但是我不想要这个宽度。 忽略下面的灰色单元格,这只是一个选定的单元格。 public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellId = "RowView0002" var cell = tableView.dequeueReusableCell(withIdentifier: cellId) if cell == nil { cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: cellId) let subView = RowView(frame: cell!.frame) cell!.contentView.attachViewWithConstraints(subView) let _ = subView.viewLoadedFromNibAttached(name: cellId) } return cell! } override […]

检测UITableViewCell上的双击和单击执行两个操作

我有一个PFQueryTableViewController ,我正在试图学习一些tableView交互。 我目前有什么:tableView单元格增加其高度didSelectRowAtIndexPath或我基本上可以segue单元相关的数据到下一个viewController使用performSegueWithIdentifier与prepareForSegue一起使用一个水龙头。 在下面的代码中,如果我注释“点击代码来增加tableView单元格的高度”代码,我可以检测到双击。 其他方面,由于代码位于didSelect块内,单击可以增加高度。 我需要的是:单击,单元格高度增加或减less。 当单元格高度增加时,如果我双击,它应该将单元格数据移到下一个UIViewController 。 如果不是这样,那么单一的水龙头应该增加或减less高度。 并且双击应该将细胞数据传递给下一个UIViewController 代码如下: var selectedCellIndexPath: NSIndexPath? var SelectedCellHeight = CGFloat() // currently set to 480.0 tableView height var UnselectedCellHeight = CGFloat() // currently set to 300.0 tableView unselected hight …. override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { if let selectedCellIndexPath = selectedCellIndexPath { if […]

基于两个子视图高度的自定义TableView单元格

TableView说明 tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 60.0 单元格说明 我有一个单元格,在ContainerView中有2个标签(Title,Description),下面是一个ImageView。 单元高度将根据“说明标签”的内容而有所不同。 所有观点的对立 有两种情况我应该处理 ContainerView.height大于(ImageView.height + ImageView.Top + ImageView.Bottom)。 这里单元格的高度将基于ContainerView.height ContainerView的高度小于(ImageView.height + ImageView.Top + ImageView.Bottom)。 在这里,我期望Cell应该考虑(ImageView.height + ImageView.Top + ImageView.Bottom)作为高度,并使ContainerView垂直居中Cell。 预期结果在这两种情况下 问题 如果我为第一种情况设置约束,那么第二种情况不起作用,反之亦然(我知道通过去除ContrainerView.Top,Bottom并使其垂直居中到SuperView情况2的结果可以实现) 有没有办法通过使用同一套IB约束和UITableViewAutomaticDimension来实现预期的结果?

错误:UITableView跳到UITableViewAutomaticDimension顶部

我正在使用UITableView与estimatedRowHeight和UITableViewAutomaticDimension 。 另外我正在使用NSFetchedResultsControllerDelegate来反映更改。 一切都很好。 现在的问题是,当我添加一些logging到CoreData , CoreData调用它的委托,但一个意想不到的事情发生。 每次TableView突然滚动到顶部。 NSFetchedResultsControllerDelegate func controllerWillChangeContent(controller: NSFetchedResultsController) { tableView.beginUpdates() } func controllerDidChangeContent(controller: NSFetchedResultsController) { tableView.endUpdates() } func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) { switch type { case .Insert: tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .None) break case .Update: tableView.reloadRowsAtIndexPaths([indexPath!], withRowAnimation: .None) break case .Delete: tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: […]

用像Instagram这样的“更多”button展开UITableView中的UILabel

我有一个项目(这是由其他人写的),其中有一个饲料的内容和文本显示在一个表视图。 每个post对应于表格视图中的一个部分,每个部分都有自己的行,对应于内容,文本,像button等元素。 我需要在表格视图单元格内使用“更多”button来显示标题的简短标签,当点击更多button时,标签将展开为标题适合的任何大小,全部发生在表格视图单元格内。 当点击更多button时,我将标签的numberOfLines属性更改为零,并且由于单元格具有自动高度,所有我需要的是重新加载该特定的标题单元格。 (如果在显示单元格之前将numberOfLines设置为0,则单元格会正确显示扩展的大小。) 我试过了: [tableView beginUpdates]; tableView endUpdates]; 我已经尝试过各种animation选项: [tableView reloadRowsAtIndexPaths:@[myPath] withRowAnimation:UITableViewRowAnimation(Bottom,Top,None etc)]; 我试过了: [tableView reloadSections:[NSIndexSet indexSetWithIndex:myPath.section] withRowAnimation:UITableViewRowAnimation(Top,Bottom,None etc)]; 但他们都产生了相同的结果:整个表视图布局变得混乱:它跳转到另一个单元格,一些视图变成空白,单元格重叠,单元格内的video停止播放,标签不扩展(但刷新内部本身,如简短的预览TXT一行从顶部/底部animation,但不扩大)。 什么可能导致整个表视图的混乱,以及如何能够正确地重新加载一个单元格和扩展animation,而不会搞乱整个布局? 我已经看到了很多关于这个的问题和答案,但是他们都推荐我已经尝试和解释过的选项。 我的应用程序的目标是iOS 8.0+ 更新:这里是相关的代码(有关与布局无关的内部工作的一些部分,删除): MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier: MyCellIdentifier forIndexPath:indexPath]; cell.delegate = self; cell.indexPathToReloadOnAnimation = indexPath; cell.shouldShortenCaption = YES; id post = self.posts[indexPath.section] ; [cell setPost:post]; return cell; 而且在setPost:里面: if(self.shouldShortenCaption){ […]