UIImage没有出现

时间:2013-02-08 12:16:47

标签: iphone ios json uiimage

我使用AFNetworking解析JSON。

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

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

这是我的代码(link to 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

1 个答案:

答案 0 :(得分: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);


}