tableview与复选标记和详细信息披露在一起

Aru*_*run 5 disclosure tableview checkmark ios

我正在制作一个包含多行选项的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)

有什么建议吗?

当选中一行时,应启用/禁用复选标记并选择公开按钮,它应打开一个新视图以编辑所选行.

Dan*_*any 1

这是我在我的应用程序之一中使用的示例代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

{

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    cell.textLabel.text=[NSString stringWithFormat:@"%@",[cellarray objectAtIndex:indexPath.row]];
    cell.textLabel.textColor=[UIColor blackColor] ;
    cell.textLabel.tag=indexPath.row;
    cell.textLabel.font=[UIFont fontWithName:@"HelveticaNeue-Bold" size:15];
    // cell.textLabel.highlightedTextColor=[UIColor colorWithRed:242.0f/255.0f green:104.0f/255.0f blue:42.0f/255.0f alpha:1] ;
    cell.selectionStyle=UITableViewCellSelectionStyleNone;


}

UIImageView *ima=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tick.png"]];
ima.frame=CGRectMake(280, 15, 14, 14);
ima.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin |UIViewAutoresizingFlexibleRightMargin;

int row = [indexPath row];
//cell.accessoryType = (row == selectedRow) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
cell.textLabel.textColor= (row == selectedRow) ? [UIColor colorWithRed:242.0f/255.0f green:104.0f/255.0f blue:42.0f/255.0f alpha:1] : [UIColor blackColor] ;
if (row==selectedRow) {

    [cell.contentView addSubview:ima];

}

UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Background.png"]];
[tempImageView setFrame:tableView.frame];

tableView.backgroundView = tempImageView;
[tempImageView release];
return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

selectedRow = [indexPath row]; // selected row is of type int  declared in .h

[tableView reloadData];


}
Run Code Online (Sandbox Code Playgroud)

这段代码在整个tableView中只有一个复选标记。您可以修改它以在其中有多个复选标记

希望这可以帮助 !!!