我有以下代碼:的UIImageView不顯示圖片
@interface NeighborProfileViewController : UIViewController {
UIImageView * profPic;
UITextView * text;
UIButton * buzz;
NSString * uid;
NSMutableData *responseData;
NSDictionary * results;
}
@property (nonatomic, retain) IBOutlet UIImageView * profPic;
@property (nonatomic, retain) IBOutlet UITextView * text;
@property (nonatomic, retain) IBOutlet UIButton * buzz;
@property (nonatomic, retain) NSString * uid;
@end
下面是我在viewDidLoad
上.m
文件
@implementation NeighborProfileViewController
@synthesize uid;
@synthesize profPic;
@synthesize buzz;
@synthesize text;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = //some URL to the picture;
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
self.profPic = [[UIImageView alloc] initWithImage: img];
}
我想我有線了通過IB
的UIImageView
正確。我有一個從UIImageView
到文件所有者中的profPic的插座。我究竟做錯了什麼?
在幾個小時的時間裏,我的腦袋正在跳動。在設置圖像之前再次分配imageview。謝謝@thelaws – sErVerdevIL 2013-01-09 06:58:35