在我的 iphone 应用程序中,uiTable 中有 4 个单元格,每个单元格都有整数值(10、12、13、14)。如何在我单击每个单元格时检索整数值? 以及如何放置 if 条件来检查单元格的值是否相同? 即
if(cell value==condition){
}
最佳答案
在 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...
}
关于ios - 如何在 iphone 中获取单元值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1570756/