Tag: uitableview

TableView选中的单元格 – 当标题滚动不见时检查标记消失,并检查新单元格

我有一个tableViewCell,在cellType的accessoryType中使用复选标记。 我有一个函数,将单元格的内容放入textField中,同样在文本字段未被选中时将其从文本字段中移除。 它似乎工作正常,但如果我检查一个单元格,并希望检查一个单元格不可见(IOW)我需要滚动tableView,被检查的单元格(现在不可见)似乎取消自己(只有当我检查一个新的可见细胞)。 多重select仅适用于可见细胞。 这是我的代码: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) let row = indexPath.row cell.textLabel?.text = painArea[row] cell.accessoryType = .None return cell } func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { //selectedRow = indexPath tableView.deselectRowAtIndexPath(indexPath, animated: true) let row = indexPath.row let cell = tableView.cellForRowAtIndexPath(indexPath) if […]

CAGradientLayer在滚动到UITableView顶部之后位置有误。 迅速

我需要在特定的UITableViewCell底部制作一个阴影。 我做了它,但是当我滚动到底部它工作正常,当我滚动到顶部阴影有错误的位置,它出现在UITableViewCell的顶部。 我尝试了几种方法,但它不适合我。 我读了这个问题和这个问题我该如何解决? func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier, forIndexPath: indexPath) as! LifelineLeaderboardTableViewCell // Configure the cell… let lifelineRecentModel = users[indexPath.row] cell.clipsToBounds = false if let currentUserID = DBHelper.instance.mainUserId { if lifelineRecentModel.user.id == currentUserID { cell.setupUserNumberLabelTextColor(true) cell.showBlueLineView(true) // cell.showShadow(true) let shadowView = UIView(frame: cell.bounds) let shadowFrame = […]

如果一个UITableViewCell有多个button,哪里是处理触摸事件的最佳位置

我以多列表格式呈现大量数据。 几乎每个列都有一个button(最多4个),每行都是一个UITableViewCell 。 我怎么能检测到button被触摸,我应该在哪里处理button的触摸事件? 我敢肯定,它不应该是一个didSelectRowAtIndexPath方法。 只要我可以检测到哪个button被按下,我就可以获取特定行中的数据并对其进行处理。 所以,我需要知道该行的indexPath ,以及按下了哪个button。

使用UITableViewController cellForRowAtIndexPath获取重复的单元格

我正在尝试使用UITableViewController创build一个表视图。 'cellForRowAtIndexPath'似乎没有正确的工作 – 我已经预先加载的照片和评论从parsing,把他们在一个数组,并希望图片,填满屏幕宽度,所以我正在做一些手动计算resize。 我正在做一些不寻常的事情,让表视图看起来是正确的,但现在的数据是重复的。 我知道这里有些东西没有得到,但是我不确定它是什么…也许我需要做其他的事来绑定数据,或者用“prepareForReuse”方法做些什么? 我已经包含了UITableViewController子类和我写的UITableCell子类的代码。 import UIKit class YouTableViewCell: UITableViewCell { var recipeId:String = "" var recipeName:String = "" var imageHeight:CGFloat = 0 var labelHeight:CGFloat = 0 // DO I NEED THIS? override func prepareForReuse() { self.textLabel!.text = recipeId //Put your label name self.imageView!.image = nil } override func setSelected(selected: Bool, animated: Bool) […]

当滚动浏览其中有一个CollectionView的TableView时崩溃

我有这个问题( UICollectionView里面的UITableViewCell – AutoLayout ) 并尝试了几个解决scheme,这是在互联网上可用我带着这个@Pablo Romeu的答案我试着他的解决scheme,现在我有一个TableView与其中的collectionView单元格(它可以dynamic地改变其大小的内容),但是当滚动浏览我的表查看它碰到这个错误: 2016-06-13 22:05:51.546 WishMeluck[3507:425240] the behavior of the UICollectionViewFlowLayout is not defined because: 2016-06-13 22:05:51.546 WishMeluck[3507:425240] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values. 2016-06-13 22:05:51.546 WishMeluck[3507:425240] Please check […]

返回到表视图时如何更改UITableViewController的选定单元格?

当您select一个单元格并移动到详细视图并通过点击back button返回到表格视图时,上次select的单元格的背景颜色将突出显示。 当从细节视图返回到表格视图时,如何突出显示另一个未被选中的单元格? 例如,对于Apple的Music应用程序,当您select并播放歌曲并通过点击next track button来更改歌曲并返回到歌曲表视图时,突出显示的单元格不是您上次收听的歌曲,而是您在表格视图中最后一次select。 但是我想要突出你上次听的歌。 那可能吗?

核心数据对象在不同的​​tableView部分

我有一个tableView与可扩展/可折叠部分和固定部分标题,我想要维护。 这是这样做的代码: – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 6; } + (NSString*) titleForHeaderForSection:(int) section { switch (section) { case 0 : return @"Overdue"; case 1 : return @"Today"; case 2 : return @"Tomorrow"; case 3 : return @"Upcoming"; case 4 : return @"Someday"; case 5 : return @"Completed"; // default : return [NSString stringWithFormat:@"Section no. %i",section […]

在核心数据的一对多关系中,存储的数据无法显示在表格视图中?

我使用核心数据来build立一个一对多的关系,我的应用程序的场景是显示受尊敬的团队的成员。 dynamic添加团队和成员。 将数据存储在成员部分时发生此问题。 数据正在存储,但不会显示在表格视图中。 我得到这个错误。 data: { memberDesignation = ""; memberImage = nil; memberName = bbgbb; teams = nil; }) returned nil value for section name key path 'Teams.teams'. Object will be placed in unnamed section 因为我是核心数据的新手,所以我犯了一个愚蠢的错误。 我无法弄清楚我做错了什么。 我会告诉我做了什么,纠正我做错了什么。 请操纵我的代码,给我的答案,没有逻辑或随机答案,因为我没有足够的时间来尝试每一种可能性。非常感谢,提前感谢。 ER模型 团队表视图控制器 import UIKit import CoreData class GroupTable: UITableViewController, NSFetchedResultsControllerDelegate { let managedObjectContext = (UIApplication.sharedApplication().delegate […]

新表格视图单元格显示为空白单元格

我一直在做一个应用程序,遇到了一些问题,所以我重build了它尽可能简单,以find错误发生的地方。 我的代码使用CoreData,我的第一个例子有在导航栏的加号button中添加新项目的代码。 换句话说,没有改变观点或继续。 这个版本正如我所期望的那样工作。 看到下面的GIF。 但是,当我做一个新的视图控制器添加新的项目,我最终得到一个空白单元格。 我在加号button后面有一个完全相同的代码。 而我只是使用show segue从tableview中获取一个普通的视图控制器。 但是,如果我退出应用程序,并启动备份,这一切都显示正确。 见下文。 如果你好奇的话,那么我将把它添加到1到3之间的一个随机数中。我的猜测是我需要对这个segue进行一些处理,但是我不知道它是什么。 我在Swift上很新,所以我有很多东西要学。 提前感谢您的帮助,您可以给我。 我想如果我能解决这个问题,我终于可以开发我的应用程序了。 再次感谢你。 下面是我的代码,它有一个segue的情况。 表视图控制器代码(Swift) import UIKit import CoreData class ListItemsTVC: UITableViewController, NSFetchedResultsControllerDelegate { // MARK: – Constants and Variables let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext var frc: NSFetchedResultsController = NSFetchedResultsController() // MARK: – App loading Functions override func viewDidLoad() { super.viewDidLoad() […]

用dequeueReusableCellWithIdentifier ios将单元格中的UImageView绑定到错误的行号

我有UITableView与包含白色图像的自定义单元格 – 当你按下它变成绿色(客户把东西放在他们的篮子里)。 – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { int volume = self.seats.count; return volume; } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { _currentSeat = [_seats objectAtIndex:indexPath.row]; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *identifier = @"seatCell"; //todo try fix bug with dequing indexes UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath]; if (!cell) { cell = […]