0
下面的代碼工作很好..的UIImage不加載圖像
scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 200, 1024, 200)];
scrollView1.contentSize = CGSizeMake(2048, 200);
scrollView1.showsHorizontalScrollIndicator = YES;
scrollView1.scrollEnabled = YES;
scrollView1.userInteractionEnabled = YES;
scrollView1.backgroundColor = [[UIColor alloc] initWithRed:0.5 green:0.8 blue:0.5 alpha:1];
[self.view addSubview:scrollView1];
但這個不是......
scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 200, 1024, 200)];
scrollView1.contentSize = CGSizeMake(2048, 200);
scrollView1.showsHorizontalScrollIndicator = YES;
scrollView1.scrollEnabled = YES;
scrollView1.userInteractionEnabled = YES;
scrollView1.backgroundColor = [[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile:@"image.jpg"]];
[self.view addSubview:scrollView1];
可能是什麼毛病的UIImage?在我的整個項目的UIImage不工作的任何地方....
在我所有的調試變量的UIImage顯示內存地址0 * 000000000即使在內存分配
注:: ScrollView1做工精細和「image.jpg的」是正確的論據。
是一個已經工作...任何想法可能是錯誤的上面的代碼。爲什麼變量內存一直顯示爲空。 – bhawesh 2013-02-23 07:37:52
initWithContentsOfFile方法將圖像數據加載到內存中並將其標記爲可清除。如果數據已清除並需要重新加載,則圖像對象將從指定的路徑再次加載該數據。這裏image.jpg不是路徑。它只是一個名字。 – 2013-02-23 07:42:20
然後根據你什麼可能是問題的解決方案...完整的圖像路徑? – bhawesh 2013-02-23 07:45:43