2016-03-25 18 views
1

yılında json yapma MyOrdersController.m dosyasında benim cellForRowAtIndexPath yöntemi ... İçinde bir TextLabel shipmentReferenceNumberTextLabel varbelirli TextLabel değerini kapma ve ardından 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; 
} 

olduğunu. Bir kullanıcı belirli bir hücreyi tıklattığında shipmentReferenceNumber değerini almam gerekir ve bununla birlikte APIRequest.m adlı bir dosyada json isteği yapmalıyım. Im, şöyle değerini kapmak çalışırken

- (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); 

} 

problem, onun im değerini kapmak isterken null baskı. Bu sorunu nasıl çözebilirim?

cevap

1

Bir diziden Lable değeri alabilirsiniz.

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

Satırın etiket değeri seçilir.

İlgili konular