2009-10-15 43 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... 
} 
相關問題