我正在制作一个包含多行选项的tableview.所以,我使用了checkmark附件类型动作.我还需要编辑/重命名所选行中的文本.
基本上,我需要在左侧放置复选标记(复选框),在单元格的右侧放置详细信息,两者都是功能性的.
下面的代码是我所拥有的复选标记,当前复选标记出现在单元格的右侧.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
TSIPAppDelegate *appDelegate = (TSIPAppDelegate *)[[UIApplication sharedApplication]delegate];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
if (cell.accessoryType==UITableViewCellAccessoryNone)
{
cell.accessoryType=UITableViewCellAccessoryCheckmark;
appDelegate.selectedFile = cellText;
if (prevSP!=indexPath.row) {
cell=[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:prevSP inSection:0]];
cell.accessoryType=UITableViewCellAccessoryNone;
prevSP=indexPath.row;
}
}
else if (prevSP!=indexPath.row){
cell.accessoryType=UITableViewCellAccessoryNone;
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
当选中一行时,应启用/禁用复选标记并选择公开按钮,它应打开一个新视图以编辑所选行.