Tag: tableviewcell

自定义表格视图单元格不能刷新

我有一个TableViewController有一个自定义的原型单元格,在Storyboard中设置标识符“regularCell”。 TableViewController属于TimelineTableViewController.swift类,单元格是在Storyboard中设置的TimelineTableViewCell.swift.swift类。 在TimelineTableViewController.swift中: override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.events.count } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = self.tableView.dequeueReusableCellWithIdentifier("regularCell", forIndexPath: indexPath) as! TimelineTableViewCell cell.selectionStyle = .None let event = events[indexPath.row] cell.content.text = event.content cell.name.text […]

Swift TableView崩溃:“缺less新可见行的单元格”

我在向tableview添加新行时遇到崩溃。 简而言之,崩溃日志说“缺less单元格为新的可见行3”。 再生产 1.将N个对象添加到数据源 2.手动添加相同数量的单元格到tableview 3.使用beginUpdates – endUpdates重新加载和animation 已知的问题 这个崩溃已经在苹果 问题上讨论过了。 他们对这个问题的解决scheme(不使用估计的细胞高度)不适合我,因为我需要2个不同高度的细胞。 我的tableview是由2个不同的单元格类组成的。 两者都有自己的标准高度,configuration如下: func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if indexPath.row % (straightsetLogs.count + 1) == 0 { return 44 } else { return tableView.rowHeight } } func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: […]

在一个pageViewController内部的tableView上滑动即可删除

我在pageViewController里面有一个tableView ,当在一个单元格上滑动以提供删除单元格的选项时,只有在某些情况下才会识别该手势,假设你非常迅速和积极地滑动。 我想这是因为它不确定滑动手势是为了pageView还是tableView 。 有没有一种方法可以明确确定滑动手势发生的位置,以便顺利显示删除button?

表格单元没有被重用的索引path

这开始发生了蓝色。 任何想法:代码: CUSTOMCLASSNAME(我已经replace了实际的类名,因为它包含了客户端的名字) 初始化我的tableView: [self.tableView registerClass:[CUSTOMCLASSNAME class] forCellReuseIdentifier:[self reuseIdentifier]]; 在行的单元格中: 嗨,标题正在打印在控制台。 这是我的cellForRow: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { AVTCheckListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self reuseIdentifier] forIndexPath:indexPath]; [self configureCell:cell atIndexPath:indexPath]; return cell; } – (void)configureCell:(AVTCheckListTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { ChecklistGroup *group = [self.checklistFetchedResultsController.fetchedObjects objectAtIndex:indexPath.section]; ChecklistItem *item = [self getChecklistItemForIndexPath:indexPath]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; [[cell cellTextView] setAttributedText:[[item checked] boolValue] […]

重复使用单元格不行 – TableView

我有一个关于我的单元格button的问题。 在我的tableView中,每一行都由一个图像,一些标签和一个button组成。 该button有一个复选标记图像。 点击时,button的图像会改变。 问题是另一个button的图像没有理由变化。 发生这个错误是因为我的单元格被重用。 我试图在TableViewCell中使用prepareForReuse方法,但没有任何反应。 我也尝试了与selectedRowAt但我没有任何结果。 请帮帮我。 图片1: 图2: 这是我的custom Cell: func custom Cell: override func prepareForReuse() { if checkStr == "uncheck"{ self.checkBook.setImage(uncheck, for: .normal) } else if checkStr == "check"{ self.checkBook.setImage(check, for: .normal) } } func isPressed(){ let uncheck = UIImage(named:"uncheck") let check = UIImage(named: "check") if self.checkBook.currentImage == uncheck{ checkStr == […]

ios 8 swift – 如何使用单独的数据源为tableview添加页脚

2天,我试图解决这个问题。 我只想添加一个页脚(自定义单元格)到我的tableview。 我有一些东西(标签,button)的视图,我已经添加了一个tableview。 要有一个干净的控制器,对于数据源我使用一个单独的文件: class MyDataSource: NSObject, UITableViewDataSource, UITableViewDelegate { … } 在我的控制器中我有: class MyViewController: UIViewController { @IBOutlet weak var myButton: UIButton! var myDatasource: MyDataSource! @IBOutlet weak var myTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() myDatasource = MyDataSource(….) myTableView.dataSource = myDatasource // Do any additional setup after loading the view. } 所以,在MyDataSource我添加了: func tableView(tableView: UITableView, […]

dequeueReusableCellWithIdentifier总是返回非零?

在dequeueReusableCellWithIdentifier返回的cell下面的经典模式总是不nil 。 为什么? 我们不应该先分配一些细胞,那么我们可以重新使用一些细胞吗? 我正在使用自定义单元格,并且它是在故事板中创build的。 (但是,如果我使用了默认的UITableViewCell,现象是相同的 – 返回的单元格总是non-nil )。 环境:Xcode 4.3.3 iOs 5.1 AlbumListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AlbumCell"]; //cell always non nil — why?? if(cell == nil){ cell = [[AlbumListCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"AlbumCell"]; }

重新加载UITableView显示错误?

我处于一个奇怪的境地。 当我尝试重新加载tableview使用reloadData()它显示以下错误。 。 。 致命错误:意外地发现零,而解包一个可选值 这是检索输出的Web服务方法 func didRecieveOutput(results:NSArray) { if results.count != 0 { userOrders = results as! NSMutableArray dispatch_async(dispatch_get_main_queue(), { () -> Void in self.orderList.reloadData() }) } } 编辑:我已经检查了我的连接以及委托和数据源。 它适用于静态数据。 但是当我调用reloadData()时,问题就来了。 我有静态数据以及dynamic(服务器数据)相同的问题。

如何同时更新每个自定义tableview单元格数据?

我正在使用Swift 3的Xcode 8.2.1。我有一个自定义UITableViewCell包含UITextView。 当我inputtextView ,自定义单元格自动增长。 这部分工作正常。 我还想在input特定的单元格时使用相同的数据更新我的其他单元格。 例如: 当我在第五个单元格中键入文本时,在第十一,十五和十八个单元格中自动input相同的数据。 那些细胞也必须自动生长。 我已经将数据添加到数组的特定索引。 但是它并没有反映在tableView 。 我如何实现这个function? 请通过以下代码我已经实现到目前为止。 这个updateCellHeight方法是一个自定义的委托方法。 这个方法在用户inputtextView时候被调用。 func updateCellHeight(indexPath: IndexPath, comment: String) { let currentCellLyricVal = self.traduzioneArray[indexPath.row]["rics"] tempIndexArray.removeAll() for (index,element) in traduzioneArray.enumerated() { let lyricVal = element["rics"] if currentCellLyricVal == lyricVal { tempIndexArray.append(index) } } for index in tempIndexArray { self.traduzioneArray[index]["ione"] = comment self.lyricsTableView.beginUpdates() self.lyricsTableView.endUpdates() […]

如何使用swift3在TableViewCell的CollectionViewCell中从服务器dynamic显示数据?

我从TableViewCell获取了json链接数据,然后从服务器检索这些数据,并在与相关TableViewCell数据的collectionView中显示。 如何在swift3中显示这些数据? 请帮帮我。 我从TableViewCell中获得了url链接(mainThemeList.main_associated_url,main_name)。 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let mainThemeList = mainHomeThemeTable[(indexPath as NSIndexPath).row] let cell = tableView.dequeueReusableCell(withIdentifier: "homecell") as! HomeCategoryRowCell DispatchQueue.main.async { cell.categoryTitle.text = mainThemeList.main_name cell.mainAssociatedURL.text = mainThemeList.main_associated_url self.prefs.set(mainThemeList.main_name, forKey: "main_name") cell.categoryTitle.font = UIFont.boldSystemFont(ofSize: 17.0) cell.collectionView.reloadData() } DispatchQueue.main.async { self.retrieveDataFromServer(associated_url: mainThemeList.main_associated_url,main_name: mainThemeList.main_name) } return cell } 然后从服务器的数据相关的URL链接数据。 private […]