我正在研究一個應用程序,在UIAlertView中顯示一些圖標以解釋它們的用法。 我這樣做,使用:UIAlertView中的圖像:CGRectMake在視網膜和非視網膜中iPhone
UIAlertView *helpAlert = [[UIAlertView alloc] initWithTitle:@"The button:\n\n is used to do... \n\n " message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 55, 40, 40)];
NSString *path1 = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"bottle_w_40.png"]];
UIImage *bkgImg1 = [[UIImage alloc] initWithContentsOfFile:path1];
[imageView1 setImage:bkgImg1];
[bkgImg1 release];
[path1 release];
[helpAlert addSubview:imageView1];
[imageView1 release];
[helpAlert show];
[helpAlert release];
它運作良好,在模擬器和我的iPhone 3GS(無視網膜顯示)。我的傢伙是關於視網膜的行爲。圖像位置會不同?我是否需要使用CGRectMake的某個scaleFactor或UIAlertview中的位置是絕對的?
只需添加與該名稱或不同大小的圖標相同的圖標? – doxsi 2012-08-17 18:06:25
對不起,我忘了指定,圖標圖片需要是第一張圖片尺寸的兩倍......所以如果bottle_w_40.pg是100x100,那麼[email protected]會是200x200。 – CBredlow 2012-08-17 18:10:03