Reputation: 7845
I'm looking for a UI element for my app that I can use to display various messages to the users. It could be "tip of the day", it could be a discount code, or it could be a clarification of what the screen they just got to is meant to do for them.
I'd love this control to be flexible and allow for all sorts of content. Buttons for dismissal, text, images etc. I'd also love to be able to customize its background, transparency, the frame etc.
I'm not 100% sure about this, but I'm told that UIPopoverViewController for the iPad can achieve something very similar to what I'm referring to, although I don't envision always requiring an arrow on one of the edges. There's a 2 year old ARC-less port of it to the iPhone called WEPopover which seems to be quite popular in the iOS community, but I'm wondering if there is perhaps something even better out there. I think the concept of "popup" is closer than "popover" to what I'm looking for.
Thank you!
Upvotes: 0
Views: 1562
Reputation: 7845
I managed to find a solution that, based on a few simple tests, seems to do the trick just fine. It's the KGModal by David Keegan. You create a content view, either programmatically or through a xib and pass it to the modal. It figures out the size, darkens the background and dismisses itself on tap on the X or outside the popup.
It's quite extensible and you should be able to modify it to suit your needs. The only challenge is that right now it's a singleton, so if you wanted to stack or queue up a bunch of them, you can't do it by allocating a series of modals. Not something you can't work around though.
Upvotes: 0
Reputation: 1047
That would be absolutely nice wouldn't it? I don't know about any prefab packages that do that, but what you need is to create a new viewController and load that into the view you are at the moment. If you set up an init of the view with specific options like size, color and whether or not you want specific buttons you are on the right track...
It is way to much to provide you with sample code because that is pretty hardcore stuff you're asking here. But to get you started:
Download the facebook IOS sdk Here and take a look at the FBDialog files... that's how they do it.
Or you could always make a view which contains a UIWebview where you load in an URL or just plain HTML you send to it. Style it like a popover and nobody will notice the difference. Init the UIViewcontroller and the load in the view with
[self.view addSubView:popOver.view];
to present it in your current view.
I know it isn't a full blown example, but I don't think there are any...
Good luck
Quick edit: You can also find the FB SDK on Github here, easier to look at the specific files... They are in the 'src' folder
Upvotes: 1