gpt4 book ai didi

ios - 如何使用 Objective C 获取 TableviewCell 选中的复选标记行值?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:10:14 25 4
gpt4 key购买 nike

我需要创建tableviewcell checkmark selected row title label and detail label values get after clicking the submit按钮。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil )
{
cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
if ([indexPath compare:self.lastIndexPath] == NSOrderedSame)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}

// UITableView Delegate Method

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

[tableView deselectRowAtIndexPath:indexPath animated:YES];
cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"Section:%ld Row:%ld selected and its data is %@ %@",(long)indexPath.section,(long)indexPath.row,cell.sector_Label.text,cell.textLabel.text);
selectedIndex = indexPath.row;
[tableView reloadData];
}



- (IBAction)Submit_Click:(id)sender {

// Here I need to get tableview cell check mark selected cell label values.

}

最佳答案

检查这个:

-(IBAction)Submit_Click:(id)sender {

// Here I need to get tableview cell check mark selected cell label values.
if (selectedIndex >= 0) {
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"detailTextLabel: %@", cell.detailTextLabel.text);
NSLog(@"title: %@", cell.textLabel.text);
}
}

关于ios - 如何使用 Objective C 获取 TableviewCell 选中的复选标记行值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34607347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com