我需要创建 tableviewcell checkmark 选中行 title 标签和 detail 点击提交后得到的标签值按钮。
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)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)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)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_Clickid)sender {
// Here I need to get tableview cell check mark selected cell label values.
}
Best Answer-推荐答案 strong>
检查一下:
-(IBAction)Submit_Clickid)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/
|