imageNamed 與 imageWithContentsOfFile的區別
UIImage imageNamed將為這個圖像提供緩存,所以如果你再次需要同一圖像時,圖像將被從內部緩存而不是從資源中加載。而壞消息也是iPhone將為此圖像提供緩存。這樣如果圖片過多就好出現內存洩露的現象。
UIImage imageWithContentsOfFile將不提供緩存。
imageWithContentsOfFile,加载的是路径!
Xcode iPhone SDK Tutorial - Assigning Image to a UIImageView
imageViw UI拉好後 別忘拉imageView (藍線)至 view contrller 再寫程式
iPhone 開發教學 - 使用 UIScrollView 筆記
.h
UIImageView* contectView;
.m
contectView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
contectView.image = [UIImage imageNamed:@"contact.png"];
[self.view addSubview:contectView];
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。