我想将带有一些文字的图像添加到UIAlertView中,就像下面的给定图像一样
这是我的代码
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please use Settings( ) to configure the phone number and image." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(160.5, 27, 15, 15)];
imageView.image = [UIImage imageNamed:@"settingIcon.png"];
[alert addSubview:imageView];
[alert show];
但是图片没有在alertview中显示。你的帮助会很明显。感谢
答案 0 :(得分:9)
是表情符号。你可以在这里找到整个表情符号的unicode:Emoji Unicode
您可以使用相应图片的unicode在警告中显示:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Midhun" message:@"\xE2\x9C\x88" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
答案 1 :(得分:2)
在IOS 6中试试这个
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please use Settings( ) to configure the phone number and image." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(160.5, 27, 15, 15)];
NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"settingIcon.png"]];
UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
[imageView setImage:bkgImg];
[alert addSubview:imageView];
[alert show];
我希望这会对你有所帮助
如果您在IOS 7中使用,我们无法在IOS 7中添加图像因为在IOS 7中删除所有addSubview功能....所以无法在IOS7中添加图像。