0

我正在使用 AFNetworking 解析 JSON。

我将 2 个图像和文本从一个视图传递到另一个视图,但我无法在 UIImage 视图上查看图像。

我可以在控制台上看到图像的链接。

这是我的代码(链接到 github)

#import "KKDetailsViewController.h"


@interface KKDetailsViewController ()

@end

@implementation KKDetailsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.textView.text = [self.importVideoMetaData objectForKey:@"description"];

    self.imageView.image = [[UIImage alloc] init];
    self.imageView.image = [UIImage imageNamed:[(NSDictionary *)self.importThumbnail objectForKey:@"hqDefault"]];


    NSLog(@" imported thumbnail %@", self.importThumbnail);


}

这是.h文件

#import <UIKit/UIKit.h>

@interface KKDetailsViewController : UIViewController

@property (weak, nonatomic) NSDictionary *importVideoMetaData;

@property (weak, nonatomic) NSDictionary *importThumbnail;

@property (weak, nonatomic) IBOutlet UITextView *textView;

@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
4

1 回答 1

0

好的,这就是我如何使它工作的:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.textView.text = [self.importVideoMetaData objectForKey:@"description"];

    NSURL *url = [[NSURL alloc] initWithString:[self.importThumbnail objectForKey:@"hqDefault"]];

    [self.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"fakeThumbnail.png"]];


    NSLog(@" imported thumbnail %@", url);


}
于 2013-02-09T12:42:49.230 回答