草庐IT

cellForRowAtIndexpath

全部标签

sdk - UITableViewCell cellForRowAtIndexPath 在第一次滚动时调用大量行

我一直在研究与UITableView和cellForRowAtIndexPath相关的问题。我想让用户能够拥有非常多的行,就像iPhone上的大量电子邮件列表一样。当我开始创建一个类时,我发现了这个问题,该类会根据需要将数据库中的记录组排队和出队,以节省内存。我发现当我的UITableViewController加载时,它会为典型的前10个索引(0到9)调用cellForRowAtIndexPath。当我在模拟器的黑色外表面区域上单击鼠标或尝试使用向上手势向下滚动UITableView时,就会出现问题。此时,所有剩余索引都会调用cellForRowAtIndexPath。即使有1000

ios - 无法在 cellForRowAtIndexPath 中设置单元格 alpha

在我的代码的一部分中,我调用了UITableViewCell*cell=(UITableViewCell*)[self.tableViewcellForRowAtIndexPath:indexPath];获取一些单元格,然后我将它们的alpha更改为.35。这有效,细胞看起来褪色了。但是,当我滚动tableview时,移出窗口然后移回的单元格不再褪色。即使在cellForRowAtIndexPath中每个禁用行的alpha设置为.35,也会发生这种情况。就在我记录cellForRowAtIndexPath中返回单元格之前NSLog(@"%f",cell.alpha);它返回.35但是,

ios - UITableView reloadData 和 cellForRowAtIndexPath - 可中断?

假设存在一个名为myTable的UITableView。假设发生了以下事件序列--表格已填满。数据源被更新了(在本例中是一个sqlite3db,但并不重要),一个NSNotifcation恰好表明有新数据,主线程收到通知然后调用[myTablereloadData].myTable的UITableViewDataSource的numberOfSectionsInTableView被调用。假设只有1个部分。myTable的UITableViewDataSource的tableView:numberOfRowsInSection:被调用。根据数据源中的行数调用多个tableView:cel

iphone - 使用 Storyboard时单元测试 cellForRowAtIndexPath

如果我从Storyboard中的标识符中取出一个单元格,我如何以单元测试方式调用cellForRowAtIndexPath而不是让单元格为零?-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{MyCustomTableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:kCustomCell];cell.guestNameText.text=self.details.guestN

ios - 使用 cellForRowAtIndexPath 从 UITableView 获取 UITableViewCell

我正在尝试从我的UITableViewController中获取子类UITableViewCell(类称为“MasterCell”),并更改IndexPath。比方说,我将获取第一行的单元格:NSIndexPath*indexPath=[NSIndexPathindexPathForRow:1inSection:0];MasterCell*cell=(MasterCell*)[self.tableViewcellForRowAtIndexPath:indexPath];这发生在我的viewWillAppear方法中。不幸的是,调试时单元格为零。我有不同的单元格/行,我必须在其中更改vi

ios - UITableviewcontroller 中的 UITableview - 重新加载时未调用 cellforrowatindexpath

两天以来我一直陷入一个愚蠢的问题。我在NavigationController中推送了一个UITableViewController。当它加载时,由于没有数据,所以空表是可见的:但是当我从服务器接收数据并调用[self.tableViewreloadData]时,numberOfRowsInSection和heightForRowAtIndexPath都会被调用,除了cellForRowAtIndexPath并且我的Controller显示时没有表格:我真的不明白为什么会这样。除cellForRowAtIndexPath外,所有数据源方法都会被调用。请有人指导我...谢谢..ActLo

iphone - 我在 cellForRowAtIndexpath 中添加了 selectRowAtIndexPath 以标记上一个选定的行但是如果滚动 tablview 它崩溃

我正在制作自定义UITableView菜单选择器组件。每次我选择特定的行时,我都会保存该行的索引路径,这样下次用户选择另一行时,人们就可以知道他之前选择的行。所以我将其添加到cellForRowAtIndexpath中-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{staticNSString*cellIdentifier=@"Cell";UITableViewCell*cell=[tableViewdequeueReusableCellW

ios - UITableViewController 不会调用 cellForRowAtIndexPath 但 numberOfSectionsInTableView 和 numberOfRowsInSection 确实设置正确

#import"AssignmentsViewController.h"#import"Assignment.h"@interfaceAssignmentsViewController()@propertyNSMutableArray*assignments;@property(weak,nonatomic)IBOutletUITableView*tableView;@end@implementationAssignmentsViewController-(id)initWithNibName:(NSString*)nibNameOrNilbundle:(NSBundle*)nibBu

ios - 如果在 tableView :cellForRowAtIndexPath 设置 cell.backgroundColor 不响应

我想用红色给某些表格行上色,所以我尝试添加-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{...initCodeherecell.backgroundColor=[UIColorredColor];cell.accessoryType=UITableViewCellAccessoryCheckmark;}出现了附属的复选标记,但没有出现红色。后来我发现将它放在tableView:willDisplayCell中就可以了。这是设计使然吗?为什

iphone - 为什么设置 UITableViewCell 颜色在 "willDisplayCell"中有效,但在 "cellForRowAtIndexPath"中无效?

为什么设置UITableViewCell的颜色在willDisplayCell中有效,但在cellForRowAtIndexPath中无效?注意事项:我正在使用此代码设置单元格的背景颜色:[cellsetBackgroundColor:[UIColoryellowColor]];当我把它放在方法中时工作-(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath如果我输入-(UITableViewCell*)t