数据未通过prepareForSegue或pushViewController传递

时间:2014-05-14 00:27:17

标签: ios objective-c pass-data

我已尝试过在视图控制器之间传递此数据的所有方法,两者都以模式方式表示为页面。

ViewController 1 .h 中的

----------

@property (strong, nonatomic) NSMutableDictionary * updatableProduct ;
//@property (strong, nonatomic) NSDictionary * updatableProduct ; //tried
ViewController 1 .m
中的

----------

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

static NSString * cellIdentifier = @"Cell";
TailorOUCell  *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

cell.updateOrder.tag = indexPath.row;
[cell.updateOrder addTarget:self action:@selector(nowUpdateOrder:) forControlEvents:UIControlEventTouchUpInside];

orderToUpdate = [orderQueryResults objectAtIndex:indexPath.row];

return cell;
}


-(void)nowUpdateOrder:(id)sender{

UIButton *senderButton = (UIButton *)sender;
updatableProduct = [orderQueryResults objectAtIndex:(long)senderButton.tag];

[self performSegueWithIdentifier:@"updateOrder" sender:updatableProduct];
//[self performSegueWithIdentifier:@"updateOrder" sender:self]; //tried

}


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if ([segue.identifier isEqualToString:@"updateOrder"]) {
    OUEditView * ouv = (OUEditView *)segue.destinationViewController;
    ouv.orderDetails = updatableProduct;
    [segue.destinationViewController setModalPresentationStyle:UIModalPresentationPageSheet];

}

}
ViewController 2中的

.h ----------

@property (strong, nonatomic) NSMutableDictionary * orderDetails ;
ViewController 2 .m
中的

----------

@synthesize orderDetails;

但是日期中的orderDetails = null

任何帮助!

1 个答案:

答案 0 :(得分:0)

您需要在代码中添加断点或日志语句,看看发生了什么。

  • 是否正在调用prepareForSegue?
  • IF语句是否与标识符匹配?
  • " updatableProduct"中的值是否为不是吗?
  • 您是否在viewDidLoad或中查看ouv.orderDetails的值? viewWillAppear,而不是在init方法? (init方法触发 在调用prepareForSegue之前。)