传递UITableView的解析XML
问题描述:
我解析XML并从UITablevView中选择,但我有一个问题,我将如何更改每个选择上的链接?传递UITableView的解析XML
例如;
www.example.com/test12.php?d=0
www.example.com/test12.php?d=1&il=istanbul
www.example.com/test12.php?d=2&il=istanbul&ilce=kadikoy
我怎样才能改变d =和IL =和ILCE =值在每个选择上的UITableView?
我已经写了这个,但不能进一步。从现在
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = selectedCell.textLabel.text;
NSString *linkID = @"http://example/[email protected]%&[email protected]%";
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;
}
感谢。
答
我会用3个不同的表格视图控制器和一个导航控制器来做到这一点。这样做可以让每个控制器都变得简单,并允许钻取级别之间有一个很好的动画,这样用户就能了解已发生了什么变化。
您的数据结构应该是包含每个城市的字典的数组。每个城市字典都包含一系列省字典。每个省字典都包含一系列地点。 (从技术上讲,这些可以是独立的数据结构,每个数据结构都有一个对所需数据的引用,但是现在让我们保持简单)。
每个表视图控制器都应该将一个数组作为其数据源。它还应该采用其他一些参数,这可能是迄今为止生成的链接。
城市视图控制器显示城市名称列表(如您当前所用)。当选择一行时,它会得到适当的城市字典,获取省份数组,创建省视图控制器并将其传递给省份列表。它还将城市组件添加到链接并将其传递给省视图控制器。
选择一个省时,将遵循上述相同的过程。
当选择一个地方时,可以添加最终的链接组件,并且链接现在完成并可以使用。
答
基本上你获取从排模型,并通过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];
}
解释什么是表视图,它与参数和在参数存储... – Wain
什么是(1,1,2),伊斯坦布尔和卡德柯伊。这家商店在哪里?在NSArary中的字典或其他地方? – CRDave
谢谢@Wain我首先展示了城市,当他们中的一个选择了它时,显示了省份,然后放置了......我没有存储任何我只是显示数据的东西。请回到我身边。 –