0

我正在尝试以这种方式在 UIAlertView 中添加图像:

UIAlertView *alertView = [[UIAlertView alloc]
                          initWithTitle:@"Accept Connection?"
                          message:[NSString stringWithFormat:@"%@ wants to connect with you", newStr]
                          delegate:self
                          cancelButtonTitle:@"No"
                          otherButtonTitles:@"Yes", nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 100, 100, 50)];
NSString *imgPath = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"BluetoothDeviceiPhone.png"]];
UIImage *yourImage = [[UIImage alloc] initWithContentsOfFile:imgPath];
[imageView setImage:yourImage];
[alertView addSubview:imageView];
[alertView show];
alertView.tag = 2;

图像没有显示,也没有显示空间,只有文本。为什么??

4

1 回答 1

3

检查此示例代码,它也在 ios7 和更早版本中运行

https://github.com/wimagguc/ios-custom-alertview

于 2013-10-30T13:16:42.547 回答