iphone sdk- UIAlertView button with image
-
19-09-2019 - |
Question
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
Solution
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.
OTHER TIPS
You can use unicode characters, which are rendered as icons. I described it here: Adding Images to UIActionSheet buttons as in UIDocumentInteractionController