ios - 如何使用 Objective C 获取 TableviewCell 选定的复选标记行值?
<p><p>我需要创建 <code>tableviewcell</code> <code>checkmark</code> 选中行 <code>title</code> 标签和 <code>detail</code> 点击提交后得到的标签值按钮。</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell* cell = ;
if(cell == nil )
{
cell =[[ initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
if ( == NSOrderedSame)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
// UITableView Delegate Method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
;
cell = ;
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;
;
}
- (IBAction)Submit_Click:(id)sender {
// Here I need to get tableview cell check mark selected cell label values.
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>检查一下:</p>
<pre><code>-(IBAction)Submit_Click:(id)sender {
// Here I need to get tableview cell check mark selected cell label values.
if (selectedIndex >= 0) {
NSIndexPath* indexPath = ;
UITableViewCell *cell = ;
NSLog(@"detailTextLabel: %@", cell.detailTextLabel.text);
NSLog(@"title: %@", cell.textLabel.text);
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何使用 Objective C 获取 TableviewCell 选定的复选标记行值?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34607347/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34607347/
</a>
</p>
页:
[1]