Iphone 在segue中加载带有已保存图像的图像视图
我使用以下代码将图像分配给ImageViewIphone 在segue中加载带有已保存图像的图像视图,iphone,ios,cocoa-touch,Iphone,Ios,Cocoa Touch,我使用以下代码将图像分配给ImageView -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"imgHand"]) { RingController *ctrl = segue.destinationViewController ; ctrl.imgHand.image = [[UII
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"imgHand"])
{
RingController *ctrl = segue.destinationViewController ;
ctrl.imgHand.image = [[UIImage alloc] initWithContentsOfFile:self.selectedPath];
}
}
但是,imgHand显示为黑色,并且没有为其指定图像
此路径中的图像确实存在,并且已将其分配给CollectionView中的图像
Printing description of self->selectedPath:
/var/mobile/Applications/79092B1E-BE77-4583-A39A-C2D4767ADA12/Documents/myHandImage1.png
您的问题是您的“imgHand
”图像视图属性未在父视图控制器的“prepareforsgue
”方法中初始化或完全合成。在这一点上它是一个空对象
从“
RingController
”中公开一个独立的“UIImage
”属性,您可以通过父级的“prepareForSegue
”方法调用设置映像,然后在RingController
的“viewDidLoad:
”中,您可以将映像视图设置为映像。还有什么问题?我在这里看不到问题。@dpassage抱歉,我编辑了代码,图像没有分配给imgHandperfect,这很有帮助:)