[英]picture won't show after segue passing
如標題所示,我試圖在UIImageview中顯示UIImage,問題是它不會顯示。 在我展示它之前,我從另一個角度通過了segue。 當我斷點時,我看到分配了UIImage但沒有圖片顯示,我嘗試將其設置為靜態圖片,並且效果很好。
相關代碼應為...
在FirstViewController.m中
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage* img = [info objectForKey:UIImagePickerControllerOriginalImage];
if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
NSLog(@"Bild hämtad!");
[self moveImage];
}
else
{
UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), Nil);
}
[picker dismissModalViewControllerAnimated:YES];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
- (void)image: (UIImage *)image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo{
if (!error) {
NSLog(@"Bild sparad!");
[self moveImage];
}
else{
NSLog(@"%@",error);
}
}
-(void)moveImage
{
[self performSegueWithIdentifier:@"ImageEdit" sender:self];
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"Bild Flyttad!");
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:self
{
if ([[segue identifier] isEqualToString:@"ImageEdit"])
{
[segue.destinationViewController setMImage:image];
}
}
在ImageEditController.m中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[imageView setImage:_mImage];
NSLog(@"Bild Visas!");
}
我知道有很多代碼,但是我認為發布多於少總比更好。
您是否曾經初始化過imageView?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
imageView = [[UIImageView alloc] init];
[imageView setImage:_mImage];
NSLog(@"Bild Visas!");
}
如果從未初始化過該函數,則對其進行的任何函數調用都只會靜默失敗(在nil指針上調用一個函數不會執行任何操作)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.