[英]Left delete icons not appearing while UITableview edit mode
I have a core data/ uitableview based app. 我有一个基于核心数据/ uitableview的应用程序。 Actually 80% of the code so far is equal to the Apple Sample app CoreDataRecipes. 到目前为止,实际上80%的代码等于Apple Sample应用程序的CoreDataRecipes。 My problem is that when I enter the edit mode (by pushing the edit button), there are no "delete badges" on the left side of the rows. 我的问题是,当我进入编辑模式(按编辑按钮)时,在行的左侧没有“删除徽章”。 Bumper. 保险杠。
The differences in code with CoreDataRecipes: CoreDataRecipes的代码差异:
What I tried: 我试过的
I checked if the editingstyle is ok. 我检查了editstyle是否还可以。 It should be by default but to make sure I added: 它应该是默认设置,但要确保我添加了:
(UITableViewCellEditingStyle)tableView:(UITableView*)tableVieweditingStyleForRowAtIndexPath(NSIndexPath*)indexPath {return UITableViewCellEditingStyleDelete;} (UITableViewCellEditingStyle)tableView:(UITableView *)tableVieweditingStyleForRowAtIndexPath(NSIndexPath *)indexPath {返回UITableViewCellEditingStyleDelete;}
I checked if the delete icons where not behind my cellview. 我检查了删除图标是否不在cellview的后面。 There are not. 没有。 I now think that the cell behaviour of moving to the right is handled by iOS. 我现在认为,向右移动的单元格行为是由iOS处理的。
Anyone any ideas? 有任何想法吗? It must be something simple. 它一定很简单。
Make sure that 确保
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
If this is not set to return YES then the badges will not be enabled. 如果未将其设置为返回YES,则将不会启用徽章。 The default is set to return NO 默认设置为返回NO
I think you have not added the line tableView.editing=YES
on clicking the Edit button 我认为您没有在单击“编辑”按钮时添加tableView.editing=YES
行
Try by setting it! 尝试设置它!
Since yours is a UIViewController, the tableview doesnt get the setEditing call. 由于您的是UIViewController,因此tableview不会获得setEditing调用。 Just add: 只需添加:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.tv setEditing:editing animated:YES];
}
Make sure you have setup the outlet/ delegate/ datasource then these: 确保已设置出口/代表/数据源,然后执行以下操作:
-(void)editButtonTapped
{
[self.tableView setEditing:YES animated:YES];
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.