我正在研究一个应用程序,在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