2009-10-15 44 views
1

在我的iphone应用程序中,我有4个单元格在uiTable中,每个单元格都有整数值(10,12,13,14)。如何在单击每个单元格时检索整型值? 以及如果条件来检查单元格的值是否相同? 也就是说如何在iphone中获取单元格值?

if(cell value==condition){ 

} 

回答

1

didSelectRowAtIndexPath方法在UITableViewController简单的提取标签文本值。

- (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... 
} 
相关问题