小编use*_*720的帖子

从UITableView中的选定单元格传递数据

我有一个tableview,其中每个单元格都填充了数组中的动态数据.从这里开始,当用户选择一行时,我想将特定数据从该单元格推送到ViewController,以便最终可以用于POST请求.现在我知道我的tableviewcontroller上的这段代码只会显示数据

- (void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *__strong)indexPath {
    DetailGameController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"Detail"];
    [self.navigationController pushViewController:detail animated:YES];
    NSUInteger row = [indexPath row];
    detail.rowNum.text = [photoTitles objectAtIndex:row];

}
Run Code Online (Sandbox Code Playgroud)

但是我如何实际使用这些数据呢?

这是我所拥有的片段(实际代码有多个NSMutableArrays,但我只包括一个):

     - (void)viewDidLoad
    {

        [super viewDidLoad];
        photoTitles = [[NSMutableArray alloc] init];
 NSURL *url = [NSURL URLWithString:@"http://localhost/test.php"];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:dataCenter.data forKey:@"name"];
    [request setDelegate:self];
    [request startAsynchronous];

}
- (void)requestFinished:(ASIFormDataRequest *)request
{

    NSString *responseString = [request responseString];

    NSDictionary *dictionary = [responseString JSONValue]; 
    NSArray *photos = [[dictionary objectForKey:@"photos"] objectForKey:@"photo"];

    for (NSDictionary *photo in …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios

2
推荐指数
1
解决办法
2529
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

uitableview ×1