gpt4 book ai didi

ios - 如何在 iphone 中获取单元值?

转载 作者:行者123 更新时间:2023-11-29 13:51:24 25 4
gpt4 key购买 nike

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

if(cell value==condition){

}

最佳答案

UITableViewControllerdidSelectRowAtIndexPath 方法中,只需提取标签文本值。

- (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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com