Tag: cell

在TableView中有select地加载单元格

我需要返回单元格tableView:cellForRowAtIndexPath:只有当某些条件为真,例如: if (condition == true) return nil; else return cell; 返回零给我一个错误。

将一个静态单元添加到UICollectionView

我有一个UICollectionView显示数组中的单元格。 我想要第一个单元格是一个静态单元格,作为一个提示,以进入创buildstream程(最终添加一个新的单元格)。 我的做法是将两个部分添加到我的collectionView中,但是我目前无法弄清楚如何在cellForItemAtIndexPath中返回一个单元格。 这是我的尝试: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { if indexPath.section == 0 { let firstCell = collectionView.dequeueReusableCellWithReuseIdentifier("createCell", forIndexPath: indexPath) as! CreateCollectionViewCell firstCell.imageView.backgroundColor = UIColor(white: 0, alpha: 1) return firstCell } else if indexPath.section == 1 { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("mainCell", forIndexPath: indexPath) as! MainCollectionViewCell cell.imageView?.image = self.imageArray[indexPath.row] return cell } […]

保持选定的单元大量reloadRowsAtIndexPaths UITableView

在其中的一个意见是有一个UITableView更新相当频繁。 跟踪更改是使用“reloadRowsAtIndexPaths” -(void)refreshCells:(NSArray *)changedCells { NSLog(@"refreshCells %i",[changedCells count]); [TableView beginUpdates]; [TableView reloadRowsAtIndexPaths:changedCells withRowAnimation:UITableViewRowAnimationBottom]; [TableView endUpdates]; } 问题:如何保留用户上次select的单元格。 每次更新refreshCells后,单元格的位置可能会改变?

swift中tableView中按下了哪个单元格button?

我已经阅读了类似这样的问题,但这些代码没有为我工作,所以请帮助:我有一个表格视图与每个单元格中的一些button – 此表视图是用户的因素,我添加button到该tableview – 当用户有付钱的button隐藏在该单元格中的因素,在另一个单元格中的另一个因素,当用户没有支付薪酬的钱不隐藏 – 这就是我想要检测哪些单元格button按下? 我知道,在表视图中,我们可以检测到哪个单元格按下但是这是不同的,因为用户只要按下该单元格中的button不按下所有的单元格 由于我的代码太长,我只是把表视图代码在这里 public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "factorCell", for: indexPath) as! FactorCell cell.factorTitle.text = factorTitle[indexPath.row] cell.factorCode.text = factorCodes[indexPath.row] cell.factorDate.text = factorDate[indexPath.row] cell.factorHour.text = factorHour[indexPath.row] cell.factorPrice.text = factorPrice[indexPath.row] cell.factorCondition.text = factorConditions[indexPath.row] cell.factorBill.tag = indexPath.row cell.factorBill.addTarget(self,action:#selector(factorViewController.Bill), for: UIControlEvents.touchUpInside) cell.factorDetail.tag = […]

为什么我们在UITableViewController中检查(cell == nil)?

我想实现基于UITableView的Application.For我selectUITableViewStyle是Group.In我的TableView他们是15节每节有1行。 – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 15; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section==12) { return 120; } else { return 60; } } 我想在第12节添加一个UITextView 为此,我做了以下代码 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == […]

UICollectionView加载更多的数据

如果最后一个单元格显示,我想从服务器获取更多的数据,但是UICollectionView没有类似于UITableview的方法-willDisplayCell。 所以我不知道这个情况,有人能告诉我该怎么办,谢谢!

iOS在tableView单元格中计算文本高度

我目前正在开发一个应用程序,它在桌面视图中显示一些鸣叫。 在故事板上,我创build了一个原型单元,其中包含推特条目的基本gui概念。 它看起来大致如下: ++++++++++++++ ++Username++++ ++++++++++++++ ++Tweet+++++++ ++++++++++++++ ++Time-Ago++++ ++++++++++++++ 现在我正在用下面的代码计算单元格的高度,但不知何故失败。 – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary * currentTweet = [tweetArray objectAtIndex: indexPath.row]; NSString * tweetTextString = [currentTweet objectForKey: @"text"]; CGSize textSize = [tweetTextString sizeWithFont:[UIFont systemFontOfSize:15.0f] constrainedToSize:CGSizeMake(630, 1000) lineBreakMode: NSLineBreakByWordWrapping]; float heightToAdd = 24 + textSize.height + 15 + 45; if(heightToAdd < 90) { […]