大佬教程收集整理的这篇文章主要介绍了ios – 在编辑模式下隐藏UITableView多重选择中的复选标记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
self.tableView.allowsMultipleSELEctionDuringEdiTing = YES; [self setEdiTing:YES animated:YES];
但是,我想通过更改其背景颜色来指示选择行,而不是通过自动显示在每行左侧的复选标记来选择. (例如,在Mail应用程序中编辑电子邮件列表时出现的,或者在this SO question中讨论过的那些.)我在大多数情况下都使用它,除了我无法获得自动创建的复选框作为将uITableView置于编辑模式的一部分,离开.
以下是我正在使用的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _Hierachy.cellCount; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { UITableViewCell *TESTCell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if(TESTCell == nil) { TESTCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reusEIDentifier:@"cell"]; } [[TESTCell textLabel] setText:@"Test Cell"]; return TESTCell; }
这是我到目前为止唯一的UITableView方法,所以其他一切都应该是默认行为.
在编辑模式下,是否有人知道如何在左侧隐藏这些复选标记?我在单元的附件部分看到了很多关于复选标记的问题,但据我了解,这是另一回事.我也看到人们谈论tableView:didSELEctRowATindexPath:方法,但这些复选标记是在表进入编辑模式时创建的,并在用户点击“完成”时被解除,因此该方法似乎不相关.
我最接近的是找到这种方法:
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEdiTingRowATindexPath:(NSIndexPath *)indexPath{ return NO; }
但这只是防止单元格的内容缩进,以便为复选标记腾出空间.复选标记仍然出现.
当然有一种隐藏这些复选标记的方法,并且仍然允许在编辑模式下进行多项选择?或者,在启用了多个选择的编辑模式下,UITableView的那些检查标记是否是严格的强制行为?
编辑:我(不情愿地)打开那些有点黑客的答案,比如移动复选标记的框架,直到它离开屏幕.此应用程序供内部使用,无需获得App Store批准.但鉴于UITableView进入编辑模式时会自动创建复选标记,我甚至不知道如何将它们作为要更改的对象.任何帮助,将不胜感激!
#import "MyCustomcatell.h" @implementation MyCustomcatell - (id)initWithStyle:(UITableViewCellStylE)style reusEIDentifier:(NSString *)reusEIDentifier { self = [super initWithStyle:style reusEIDentifier:reusEIDentifier]; if (self) { // Initialization code } return self; } - (void)setSELEcted:(BOOL)SELEcted animated:(BOOL)animated { [super setSELEcted:SELEcted animated:animated]; // Configure the view for the SELEcted state } - (void)setSELEctedBACkgroundView:(UIView *)SELEctedBACkgroundView { //Cell SELEcted Color: CLEAR [super setSELEctedBACkgroundView:SELEctedBACkgroundView]; } - (void)setEdiTing:(BOOL)ediTing animated:(BOOL)animated { //Cell Edit Mode NO Indent & SELEcted Color: CLEAR [super setEdiTing:NO animated:animated]; [self setNeedsLayout]; } @end
执行此操作后,转到Inteface Builder并使您的单元格成为MyCustomcatell类的一部分.
在IB中将单元格作为MyCustomcatell类的一部分后,在UITableViewController中导入MyCustomcatell.h并在代码中修改以下内容:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { MyCustomcatell *TESTCell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if(TESTCell == nil) { TESTCell = [[MyCustomcatell alloc] initWithStyle:UITableViewCellStyleDefault reusEIDentifier:@"cell"]; } [[TESTCell textLabel] setText:@"Test Cell"]; return TESTCell; }
更新:
您还可以在TableView的tableView中执行以下操作:ediTingStyleForRowATindexPath:
- (UITableViewCellEdiTingStylE)tableView:(UITableView *)tableView ediTingStyleForRowATindexPath:(NSIndexPath *)indexPath { return UITableViewCellEdiTingStyleNone; }
这样做你应该很好!我刚试过它,它的工作方式就是你想要的!
以上是大佬教程为你收集整理的ios – 在编辑模式下隐藏UITableView多重选择中的复选标记全部内容,希望文章能够帮你解决ios – 在编辑模式下隐藏UITableView多重选择中的复选标记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。