Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone sdk- UIAlertView button with image

can you please tell me if it is possible to use an uiimage view as uialertview button "text"? i was unable to find the answer googling..

thanks a lot

like image 933
kossibox Avatar asked Feb 04 '26 13:02

kossibox


1 Answers

Yes, it is possible, but I wouldn't recommend it. You'd have to run through the UIAlertView's subviews until you find one that is of the right class, I would assume UIButton, and add your UIImageView on top like this:

for (UIView *v in [myAlertView subviews]) {
    if ([v isKindOfClass:[UIButton class]]) {
        //IF I AM THE RIGHT BUTTON
            [v addSubview:myUIImageView];
    }
}

To determine the correct button, you might initially give it some odd text like "foobar5" and test each button to see if that is its text, and if so, remove the text and add the UIImageView.

like image 151
David Kanarek Avatar answered Feb 07 '26 05:02

David Kanarek