我的警报视图中显示的图像很好。但是当我选择制作一个基于标签栏的应用程序并使用与以前完全相同的代码时,图片只是没有出现,知道为什么会这样吗?
这是我在基于单一视图的应用程序中运行良好的代码:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"AlertView"
message:@"\n"
@"\n"
@"\n"
@"\n"
@"\n"
@"Created by: \n"
@"Just testing \n"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"QWER Ahri.jpg"]];//add Icon.png
logo.contentMode = UIViewContentModeScaleToFill;
logo.frame = CGRectMake(90, 40, 100, 120);
[alert addSubview:logo];
[alert show];
我也尝试过这种方法,它在基于单视图的应用程序中确实工作得很好,就像前一个一样,但在基于标签栏的应用程序中却不行,
UIAlertView *successAlert = [[UIAlertView alloc] initWithTitle:@"Ahri is good with" message:@"Vayne, Ezreal, Caitlyn, Katarina, Alistar, Leona, Miss Fortune, Taric" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-15, -147, 314, 85)];
NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"QWER Ahri.jpg"]];
UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
[imageView setImage:bkgImg];
[successAlert addSubview:imageView];
[successAlert show];
任何帮助将不胜感激:)