テーブルビューとUIViewがあります。テーブルビューセルには画像付きのセルがあります。パーティキュラーセルを選択すると、対応する画像がUIViewの「UIImageオブジェクト」に表示されます。
テーブルビュークラスの場合:
//I'm getting temp image as following(in my "cellForRowAtIndexPath" method)
if(indexPath.row == 0)
{
[[cell imageView]setImage:[UIImage imageNamed:@"greekChickenSalad.png"]];
tempImage = [UIImage imageNamed:@"greekChickenSalad.png"];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"SubRecipeDescriptionSegue"])
{
RecipeDescriptionViewController *rdVC;
rdVC = segue.destinationViewController;
rdVC.parentIndexRDVC = descriptionIndexPath;
rdVC.DescriptionLabel = (UILabel*)subRecipeSelected;
rdVC.image = tempImage;
}
}
UIViewで、LoadViewメソッドは次のように画像を追加します。
NSData *imageDataString = UIImagePNGRepresentation(image);
NSString *imageNamedContent = [[NSString alloc]initWithBytes:[imageDataString bytes] length:[imageDataString length] encoding:NSASCIIStringEncoding];
UIImage *image1 = [UIImage imageNamed:imageNamedContent];
UIImageView *imageView = [[UIImageView alloc]initWithImage:image1];
imageView.frame = CGRectMake(30,30, 250, 100);
[self.view addSubview:imageView];
上記のコードでは、画像をNSString([UIImage imageNamed:imageNamedContent])に変換しています-これは正しいですか?
そうでない場合、どうすればこれを行うことができますか?
注:テーブルセルのテキストをUIViewのラベルに渡す場合、Segueは正常に機能しています。
私の質問が明確であることを願っています。