I need to know the following;
1.) I need to add an image to a UIAlertView programatically (if this is not allowed or permitted by apple, then some other legal way of doing it) ?
2.) What are private APIs ? and how can i distinguish one ?
I need to know the following;
1.) I need to add an image to a UIAlertView programatically (if this is not allowed or permitted by apple, then some other legal way of doing it) ?
2.) What are private APIs ? and how can i distinguish one ?
1.) Do the Following:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
[alert addSubview:imageView];
[alert show];
2.) API not in the Documentation are private API shouldn't be used.
Hezi has a good answer and it might work; but check out the documentation for UIAlertView
, specifically this section:
Subclassing Notes The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
(that last sentence is the important thing here).
I recommend creating your own UIView
subclass which looks like a UIAlertView and then you can add it (and an image or whatever else you want to put in there) as a subview and you won't have unexpected breakage if Apple does something to the UIAlertView
class to make its innards even more private.
As for Apple's private API's (and private frameworks), if you want to sell on the Apple App Store... do not even think of making use of them. Apple rejects apps for trying to do that. Now, if you want to do this as a jailbroken app and not meant to be sold on the Apple Store, you might be able to get away with it. Here is a related StackOverflow question that talks more about them.