0

現在、plist を使用してテーブル ビューの行 (つまり、名前、説明、画像) を設定しています。ユーザーが行を選択すると、行のイメージを全画面表示する imageView で新しいコントローラーがプッシュアップされます。

私が直面している問題は、文字列を新しいviewControllerのimageViewに渡すことです。

すべての NSLog は正しい情報を返しますが、UIImageView をログに記録すると null が返されます。正しく接続していませんか?行は、選択されるまで画像を表示しません (基本的に、行はサムネイルのように機能しています)。

どんな助けでも大歓迎ですありがとう!!!

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSDictionary *childDictionary = [mainChildren objectAtIndex:indexPath.row];

    //Image Name NSString from plist
    childImage = [childDictionary objectForKey:@"Child Image"];

    if ([childDictionary objectForKey:@"Child Image"] == nil) {

        NSLog(@"No Image String Found.");
    }

    else {

        NSLog(@"Image String Found. Image Name is: %@", childImage);

        UIImage *myImage = [UIImage imageNamed:childImage];
        NSLog(@"Image Found. Image is: %@", myImage);

        UIImageView *childImageView = [childImageView setImage:myImage];        
        NSLog(@"ImageView Found. ImageView is: %@", childImageView);

        FullscreenImageViewController *imgViewer = [[FullscreenImageViewController alloc] init];
        imgViewer.fullScreenImageView = childImageView;
        [self presentViewController:imgViewer animated:YES completion:nil];
    }
}
4

1 に答える 1

1

新しい UIImageView をインスタンス化すると、[[UIImageView alloc] initWithImage:image] になります。

または、フル スクリーン イメージ コントローラーにはイメージ ビューのプロパティ (fullScreenImageView など) があるため、UIImage インスタンスを使用してプロパティのイメージを直接設定できます。

于 2013-05-28T00:26:28.867 に答える