gpt4 book ai didi

ios - 如何将 [didSelectRowAtIndexPath] 选中的单元格变成字符串供以后使用

转载 作者:行者123 更新时间:2023-11-29 12:45:37 25 4
gpt4 key购买 nike

我正在寻找一种方法来添加通过 didDismissWithButtonIndex: 方法在表中选择的 didSelectRowAtIndexPath:“单元格名称”:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {


Database *currentStore = [DBList objectAtIndex:indexPath.row];

NSString *requestStr = @"http://";
requestStr = [requestStr stringByAppendingString:hostTextField.text];
requestStr = [requestStr stringByAppendingString:@":8080/compfile2.php?password="];
requestStr = [requestStr stringByAppendingString:passwordTextField.text];
requestStr = [requestStr stringByAppendingString:@"&db=latinbites"];
requestStr = [requestStr stringByAppendingString:currentStore];


}

显然,

Database *currentStore = [DBList objectAtIndex:indexPath.row];

不正确。有什么方法可以在选定的单元格行上放置一个字符串?

最佳答案

我相信我了解您想要实现的目标。尝试以下代码:-

没有。 1 - 使用 NSString 声明一个属性

@interface TableViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) NSString * selectedCellName;
@end

没有。 2 - 在 didSelectRowAtIndexPath

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
self.selectedCellName = cell.textLabel.text;
}

没有。 3 - 在 didDismissWithButtonIndex 中,附加单元格名称。

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {

NSString *requestStr = @"http://";
requestStr = [requestStr stringByAppendingString:hostTextField.text];
requestStr = [requestStr stringByAppendingString:@":8080/compfile2.php?password="];
requestStr = [requestStr stringByAppendingString:passwordTextField.text];
requestStr = [requestStr stringByAppendingString:@"&db=latinbites"];
requestStr = [requestStr stringByAppendingString:self.selectedCellName];
}
}

关于ios - 如何将 [didSelectRowAtIndexPath] 选中的单元格变成字符串供以后使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23749577/

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