我的警报视图中显示的图片很好。但是,当我选择制作基于标签栏的应用程序并使用与以前完全相同的代码时,图片似乎没有出现,不知道为什么会出现这种情况?
这是我的代码在基于单一视图的应用程序中运行良好:
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];
任何帮助都将受到高度赞赏:)