Ios 在DidSelectRowatineXpath中获取特定textlabel的值并生成json
以下是MyOrdersController.m文件中我的cellForRowAtIndexPath方法Ios 在DidSelectRowatineXpath中获取特定textlabel的值并生成json,ios,uitableview,didselectrowatindexpath,Ios,Uitableview,Didselectrowatindexpath,以下是MyOrdersController.m文件中我的cellForRowAtIndexPath方法 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; cell = (UITableViewCell *)[tableView dequeueReusableCel
- (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;
}
我有一个textlabelShipmentReferenceNumber textlabel
。当用户单击特定单元格时,我必须获取shipmentReferenceNumber
的值,并且我必须在一个名为APIRequest.m的文件中使用它发出json请求。我试图抓住它的价值如下
- (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
。如何解决此问题。您可以从数组中获取标签的值
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSLog(@"%@",amountArray[indexPath.row]);
}
您将获得所选行的标签值。您可以从数组中获得标签值
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSLog(@"%@",amountArray[indexPath.row]);
}
您将获得选定行的标签值