在我的应用程序中,我有一个 UIImagePickerController。选择图像后,我的视图控制器需要获取图像并将其传递给另一个视图控制器,该视图控制器被推送到 self.navigationController。但我总是得到 SEGFAULTS 或 nil 参数,诸如此类。如果您能告诉我这段代码有什么问题,我将不胜感激:
FirstViewController.m:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
self.currentpicture = [img copy];
[self dismissModalViewControllerAnimated:YES];
[self goNext];
}
-(void)goNext{
SecondViewController *vc = [[SecondViewController alloc] initWithNibName:@"Second" bundle:nil];
[vc giveMePicture:currentpicture];
[self.navigationController pushViewController:vc animated:YES];
}
SecondViewController.m:
-(void)giveMePicture:(UIImage *)data {
self.currentpicture=[data copy];
}
它们都将 currentpicture 定义为 UIImage *currentpicture;
我现在应该有 currentpicture 作为一些数据,但它每次都崩溃!我尝试了很多不同的事情,但我无法弄清楚。