0

I am trying to add an image in a UIAlertView in this way:

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;

The image is not showing though, neither a space is showing, just the text. Why??

Alessandro
  • 4,000
  • 12
  • 63
  • 131

1 Answers1

3

check this sample code it also running in ios7 and prior

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

kirti Chavda
  • 3,029
  • 2
  • 17
  • 29