在我的应用程序中,我有一个UIImagePickerController。当选择图像时,我的视图控制器需要获取图像并将其传递给另一个被推入到self.navigationController的视图控制器。但我总是得到SEGFAULTS或nil参数等问题。如果您能告诉我这段代码有什么问题,我会很感激:
FirstViewController.m:
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];
}
他们都定义了一个UIImage *currentpicture作为当前图片;
现在我应该有一些数据作为currentpicture,但每次都会崩溃!我尝试了许多不同的方法,但是无法解决这个问题。