2016-03-25 5 views
1
でJSONを作る

続いて、私はそれにtextlabel shipmentReferenceNumberTextLabelを持っている...が特定textlabelの値をつかみ、didSelectRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    UITableViewCell *cell = nil; 
    cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""]; 

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

    self.shipmentReferenceNumberTextLabel = [[UILabel alloc]init]; 

    self.shipmentReferenceNumberTextLabel.text = amountArray[indexPath.row]; 
    self.shipmentReferenceNumberTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10]; 


    tableView.tableFooterView = [UIView new]; 

    cell.layer.borderWidth = 1.0; 
    cell.layer.cornerRadius = 10; 
    cell.layer.borderColor = [UIColor blackColor].CGColor; 

    [cell.contentView addSubview:self.productAmountLabel]; 
    [cell.contentView addSubview:self.productAmountTextLabel]; 

    return cell; 
} 

MyOrdersController.mファイルの私のcellForRowAtIndexPathメソッドです。ユーザーが特定のセルをクリックしたときにAPIRequest.mという名前のファイルでjsonリクエストを行う必要がある場合、shipmentReferenceNumberの値を取得する必要があります。イム、次のようにその値を取得しようとして

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 
    tabBar = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"]; 
    [self.navigationController pushViewController:tabBar animated:YES]; 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    MyOrdersController *detailVC = [[MyOrdersController alloc]init]; 
    NSLog(@"%@", detailVC.shipmentReferenceNumberTextLabel.text); 

} 

問題がある、というそのイムはその値を取得しようとしているときにnullを印刷します。どうすればこの問題を解決できますか?

答えて

1

Lableの値は配列から取得できます。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 
     NSLog(@"%@",amountArray[indexPath.row]); 
} 

選択した行のラベル値が表示されます。

関連する問題