ios - 使用segue传递图像时指针类型不兼容? objective-c Xcode

标签 ios objective-c uiimageview segue

当我尝试使用segue在第二个viewController上更改图像时,出现一个问题:

分配给“NSArray”的“UIimage * _Nullable”的指针类型不兼容

我的代码是这样的:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
 if ([[segue identifier] isEqualToString:@"the_segue"]){

   SecondViewController *transferViewController = [segue destinationViewController];

   transferViewController.theimageView.image=@"photo.jpg";
   }
}

谁能帮助我告诉我如何解决它,谢谢!

最佳答案

您正在将theimageView的image属性(即UIImage)分配给字符串。

我想你想要的是transferViewController.theimageView.image = [UIImage imageNamed:@"photo.jpg"];

关于ios - 使用segue传递图像时指针类型不兼容? objective-c Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41146075/

相关文章:

objective-c - 意外删除 Bridging-Header.h 文件

ios - 在 UIScrollView 中设置大图像

ios - UITableView的reloadRowsAtIndexPaths : seems to break insertRowsAtIndexPaths:

ios - iOS 上的 CocoaHTTPServer : set up server so user can download NSData as file

ios - 如何使用 swift 4 在 objective-c 类中符合 swift 类委托(delegate)?

objective-c - NSBezierPath:创建一个 "curved"正方形

ios - Swift - 根据 REST 数据将图像分配给相应的 ImageView socket

ios - UIImage 数组没有出现在 ios 模拟器中

ios - 无法使用 Java 使用 ionic 3 FCM token 将 iOS 设备 token 注册到 azure 通知中心

ios - Epos打印机iOS SDK