大佬教程收集整理的这篇文章主要介绍了ios – 自定义UITableViewCell,UITableView和allowsMultipleSelectionDuringEditing,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-> UIViewController ---> UITableView ----> CustomUITableViewCell
其中UIViewController是UITableView的委托和数据源(出于需求原因,我使用的是UIViewController而不是UITableViewController,我无法更改它).像下面的代码一样将单元格加载到UITableView中.
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowATindexPath:(NSIndexPath *)indexPath { CustomTableViewCell *cell = (CustomTableViewCell*)[tv dequeueReusableCellWithIdentifier:kCellTablEIDentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCellXib" owner:self options:nil]; cell = self.customTableViewCellOutlet; cell.SELEctionStyle = UITableViewCellSELEctionStyleNone; } // configure the cell with data [self configureCell:cell aTindexPath:indexPath]; return cell; }
已从xib文件创建单元接口.特别是,我创建了一个新的xib文件,其中superview包含一个UITableViewCell元素.为了提供自定义,我将该元素的类型设置为CustomUITableViewCell,其中CustomUITableViewCell扩展了UITableViewCell.
@interface CustomTableViewCell : UITableViewCell // do stuff here @end
代码效果很好.在表格中显示自定义单元格.现在,在应用程序执行期间,我将allowsMultipleSELEctionDuringEdiTing设置为YES,然后进入UITableView的编辑模式.看起来很有效.实际上,每个单元格旁边都会出现一个空圆圈.问题是,当我选择一行时,空圆圈不会改变其状态.理论上,圆圈必须从空变为红色复选标记,反之亦然.似乎圆圈仍然位于单元格的contentView之上.
- (NSArray *)indexPathsForSELEctedRows
并且在编辑模式中选择时会更新.它显示正确的选定单元格.
对我来说不太清楚的是,当我尝试在没有自定义单元格的情况下工作时,仅使用UITableViewCell,圆圈会正确更新其状态.
你有什么建议吗?先感谢您.
> multi-select-table-view-cell-and-no-selection-style
> uitableviewcell-how-to-prevent-blue-selection-background-w-o-borking-isselected
这里的代码:
- (void)awakeFromNib { [super awakeFromNib]; self.BACkgroundView = [[[UIImageView alloc] initWithImage:[UIImage imagenamed:@"row_normal"]] autorelease]; self.SELEctedBACkgroundView = [[[UIImageView alloc] initWithImage:[UIImage imagenamed:@"row_SELEcted"]] autorelease]; } - (void)setSELEcted:(BOOL)SELEcted animated:(BOOL)animated { if(SELEcted && !self.isEdiTing) { return; } [super setSELEcted:SELEcted animated:animated]; } - (void)setHighlighted: (BOOL)highlighted animated: (BOOL)animated { // don't highlight } - (void)setEdiTing:(BOOL)ediTing animated:(BOOL)animated { [super setEdiTing:ediTing animated:animated]; }
希望能帮助到你.
以上是大佬教程为你收集整理的ios – 自定义UITableViewCell,UITableView和allowsMultipleSelectionDuringEditing全部内容,希望文章能够帮你解决ios – 自定义UITableViewCell,UITableView和allowsMultipleSelectionDuringEditing所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。