0

XML を解析していて、UITablevView から選択していますが、各選択のリンクをどのように変更するかという問題がありますか?

例えば;

www.example.com/test12.php?d=0

www.example.com/test12.php?d=1&il=イスタンブール

www.example.com/test12.php?d=2&il=istanbul&ilce=kadikoy

UITableView の選択ごとに d= と il= と ilce= の値を変更するにはどうすればよいですか?

私はこれを書きましたが、それ以上進むことができませんでした。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = selectedCell.textLabel.text;

NSString *linkID = @"http://example/test12.php?d=@%&il=@%";

NSLog(@"%@ Selected", cellText);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 static NSString *CellIdentifier = @"Cell";
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

containerObject = [objectCollection objectAtIndex:indexPath.row];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                  reuseIdentifier:CellIdentifier];
}

// Set up the cell...
cell.textLabel.text = containerObject.city;
return cell;
}

今からありがとう。

4

2 に答える 2

1

基本的に、行からモデルを取得し、stringWithFormat を介して値を挿入します。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    YourModel* containerObject = [objectCollection objectAtIndex:indexPath.row];    
    NSString *linkID = [NSString stringWithFormat:@"http://example/test12.php?d=%@&il=%@", containerObject.var1, containerObject.var2]; 
}
于 2013-06-25T10:26:19.373 に答える