【问题标题】:how to get cell value in iphone?如何在iphone中获取单元格值?
【发布时间】:2009-10-15 07:19:30
【问题描述】:

在我的 iphone 应用程序中,我在 uiTable 中有 4 个单元格,每个单元格都有整数值(10、12、13、14)。单击每个单元格时如何检索整数值? 以及如何设置 if 条件来检查单元格的值是否相同? 即

if(cell value==condition){

}

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    UITableViewController 中的didSelectRowAtIndexPath 方法中,只需提取标签文本值。

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        NSString *s = [[[tableView cellForRowAtIndexPath:indexPath] textLabel] text];
        NSLog(@"String is: %@", s);
    
        int i = [s intValue];
        NSLog(@"This is the int value: %d", i);
    
        // Compare string or int to other value...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-02
      • 2017-11-25
      • 1970-01-01
      • 2012-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多