It seems that I am always fighting with UIAlertView to make it do what I want. I'm done fighting - are there any robust UIAlertView replacements with the following features, or will I need to write my own?:
ability to customize the alert-view size/position
ability to change the layout of the
buttons (stacked vs. side-by-side)
ability to prompt users for input via UITextField or UITextView
resizing / repositioning behavior
when the keyboard appears
ability to have a UITextView for
scrolling text
pixel-perfect copy of UIAlertView for
basic display
ideally interface compatible with
UIAlertView - i.e. it is a drop-in-replacement.
I've found a few blog and stackoverflow posts which implement customizations on a UIAlertView - this is NOT what I want. Nor do I want a guide on how to implement a custom AlertView -- I know how, I just want to find one that is already community maintained. I want a ground-up replacement that is safe for App Store submission and future-proof against UIAlertView changes (yes, I've been burnt...)
Please respond with comments if you have suggestions for other desirable features.
Answering my own question.
I searched high and low for a prefab UIAlertView project that offered the features I was looking for. I'm sure they exist -- I've seen apps with great alerts. Their authors must not be sharing - which is totally fine, I understand.
So I wrote my own. TSAlertView is a ground-up implementation of a modal alert view that is interface-compatible with UIAlertView. In terms of visual look, while it is not a pixel-perfect copy, it comes very close. The features it offers are basically what I outlined in the original question:
ability to set the display-width and max-height of the alert view. This allows me to have nicer looking alerts on iPad.
ability to specify the layout of the buttons (stacked vs. side-by-side), even if there are only two buttons. This always bothered me with UIAlertView -- if I had two buttons they were always placed side-by-side. A big problem if the button text didn't fit.
ability to prompt users for input via a UITextField. Once in a while you just need a quick and dirty way to prompt the user to enter something.
resizing / repositioning behavior when the keyboard appears. (happens when prompting for user-input)
ability to have a UITextView for scrolling text. Can explicitly set this option instead of relying on UIAlertView to swap in a UITextView for long text.
near pixel-perfect copy of UIAlertView for basic display.
support for custom backgrounds
is interface compatible with UIAlertView - i.e. it is a drop-in-replacement.
I've used a handful of great open-source projects in my code in the last year. My two favorites are MBProgressHUD and MGSplitViewController, each hosted at github. I decided to share TSAlertView in the same manner.
https://github.com/TomSwift/TSAlertView
The initial implementation surely has some bugs. I haven't used it in a shipping project yet, but I am using it in my current project to be completed in a few weeks. If you want to try using it yourself, please feel free. Post any issues on github, or better yet, submit a fix.
Enjoy!
Here are some screenshots showing 1) 2 stacked buttons 2) input capability 3) explicit width setting
Check out Smart Alert View, it's open-source.
Check my own Alert view replacement - get app here. https://github.com/FeminaErnest/GeekyFemi. Good luck
Related
I am trying to make an update for my trivia app and want it so that when the user types in the answer he/she only has the option to click A,B,C, or D. Is this possible? and if so, would apple allow this and how do I do it?
You could also just create a custom view with four buttons that appears when necessary. It would be easier than customizing the keyboard, and depending on how you design and implement it, it'll probably look better than an action sheet. UIView provides a rich set of methods to animate views with ease.
Yes, you can customise the keyboard, all the documentation is in the developer library. But it sounds to me you'd be better off using a UIActionSheet if all you are doing is picking from four options.
Edit: For reference, have a look at Custom Views for Data Input in Apple's Text Programming Guide for iOS.
What can be used instead of tooltip in iphone app?
Best alternative of tooltip in touch screen systems?
Tooltips are generally reserved for operating systems that have a cursor. In touchscreen applications, tooltips should not be needed at all. When your application is in use, the user should always know where the menus are, what all of the buttons do, etc, simply because they have been labeled clearly with a text explanation or an image.
If you need the use of tooltips in your application, you need to rethink your design.
Be Succinct.
I believe tooltips are still viable in form of short timed message. For instance, you may show dialog when button can be single-clicked or long-pressed. How else would you describe to user that functionality. None of the solutions above seem to work in this case. I guess timed message, some kind of dialog and help file are only options. Or am I missing something?
You don't. Instead apply a stronger preference for text buttons over buttons with an icon. Sometimes a footer message describes the current status in more detail.
(this is just me, interpreting Apple app design as good practice)
Tooltips can be useful especially for icons or image that are not or cannot be labeled and also for multilingual apps where different text lengths must be taken into account. It's not always a question of rethinking your whole design, for me it depends on the context of your app. An design doesn't fail just because tooltips have to be added.
Safari on iPhone and iPad uses the method touch and hold on a link. This very near the actual hover and hold for desktop apps. This is also the direction we are looking at in my company.
Ref.:
http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
Regards,
When you select text message from a contact in the contact's app you get a list of phone numbers and email addresses with the 'type' also in the button, however the 'type' is styled differently. Is there a way to get this effect with UIActionSheet buttons or would I have to roll my own?
There's no officially supported way to do this. You might be able to dig through the view hierarchy and add subviews to the buttons containing text that's styled the way you want it, but it's a bad idea because:
It'll probably break in a future release when Apple changes how they organize the view in an action sheet.
Even if they don't change the views, they may change how they look, leaving your stuff looking very odd in its new context.
If you roll your own, there's still the chance your "action sheet" will look different from all of the other ones on the system, but at least it'll look exactly how you intended it to look.
I have a problem. Part of my app requires text to be shown in a table. The text needs to be selectable/copyable (but not editable) and any URLs within the text need to be highlighted and and when tapped allow me to take that URL and open my embedded browser.
I have seen a couple of solutions that solve one of either of these problems, but not both.
Solution 1: Icon Factory's IFTweetLabel
The first solution I tried was to use the IFTweetLabel class made possible by Icon Factory and used in Twitterrific.
While this solution allows for links (or anything you can find with a regex) to be detected to be handled on a case by case basis, it doesn't allow for selecting and copying.
There is also an issue where if a URL is long enough to be wrapped, the button that the class overlays above the URL to make it interactive cannot wrap and draws off screen, looking very odd.
Solution 2: Use IFTweetLabel and handle copy manually
The second thing I tried was to keep IFTweetLabel in place to handle the links, but to implement the copying using a long-tap gesture, like how the SMS app handles it. This was just about working, but it doesn't allow for arbitrary selection of text, the whole text is copied, or none is copied at all... Pretty black and white.
Solution 3: UITextView
My third attempt was to add a UITextView as a subview of the table cell.
The only thing that this doesn't solve is the fact that detected URLs cannot be handled by me. The text view uses UIApplication's openURL: method which quits my app and launched Safari.
Also, as the table view can get quite large, the number of UITextViews added as subviews cause a noticeable performance drag on scrolling throughout the table, especially on iPhone 3G era devices (because of the creation, layout, compositing whenever a cell is scrolled on screen, etc).
So my question to all you knowledgeable folk out there is: What can I do?
Would a UIWebView be the best option? Aside from a performance drag, I think a webview would solve all the above issues, and if I remember correctly, back in the 2.0 days, the Apple documentation actually recommended web views where text formatting / hyperlinks were required.
Can anyone think of a way to achieve this without a performance drag?
Many thanks in advance to everyone who can help.
As soon as I hit the submit button, a new idea hit me.
I was so preoccupied with having URLs inline with text and interactive that I didn't consider that maybe it's not the best solution.
I'm certain that to achieve that kind of behaviour, a UIWebView is the best choice, regardless of the performance issues.
However, maybe a better user experience / interaction is to not highlight the URLs inline, but to gather them into an array behind the scenes, and present a disclosure button as the cell's accessory view?
Then for selection and copying text, I could just use the UITextView with data detectors turned off and not worry about the links being sent off to safari and closing my app.
When the disclosure button is tapped, the user could be whisked off to the URL found in the text, or if more than one URL is found, present the user with a picker view to choose which to go to.
Any thoughts/criticisms of this idea are welcome.
You can prevent a textfield from being edited by overriding the UITextField Delegate methods such that they do not apply any edits. That leaves the field selectable and copyable but prevents alteration.
A better question to ask is: do you actually have to display the actual URL itself? Can you get away with just a page/location name, just the server.host.domain prefix or some other condensed representation of the url? I don't think anyone whats to try to read a long url on a mobile's restricted screen.
If you do need to display the entire url then I think that a detail view is the way to go.
I discovered somewhat by accident that if you make a UIButton in Interface Builder and type in Plus in the image field, a + image appears for the button. A similar result comes from typing Minus.
I am wondering if this is a bug, or if there is some way the poor programmers can access the built-in general GUI images from other apple apps, such as the green +, the red -, the detail disclosure chevron, the big red "Delete Contact" or similarly styled button, etc.
Has anyone else encountered this, or know where to access these things in Xcode?
It makes sense to me that they should be usable, cause the Apple HIG seems to be all about making things recognizable and intuitive, and using them the way other apps use them.
You can get the UITabBarItems and once there search for UIBarButtonItem. Scroll towards the bottom of the screens and you can see all the system images for Tab Bars and Navigation Bars.
I found an up-to-date (iOS7) list of icons for UIBarButtonSystemItem on the official iOS Developer Library, which could be helpful.
UIBarButtonSystemItemDone
UIBarButtonSystemItemCancel
UIBarButtonSystemItemEdit
UIBarButtonSystemItemSave
UIBarButtonSystemItemAdd
UIBarButtonSystemItemFlexibleSpace
UIBarButtonSystemItemFixedSpace
UIBarButtonSystemItemCompose
UIBarButtonSystemItemReply
UIBarButtonSystemItemAction
UIBarButtonSystemItemOrganize
UIBarButtonSystemItemBookmarks
UIBarButtonSystemItemSearch
UIBarButtonSystemItemRefresh
UIBarButtonSystemItemStop
UIBarButtonSystemItemCamera
UIBarButtonSystemItemTrash
UIBarButtonSystemItemPlay
UIBarButtonSystemItemPause
UIBarButtonSystemItemRewind
UIBarButtonSystemItemFastForward
UIBarButtonSystemItemUndo
UIBarButtonSystemItemRedo
UIBarButtonSystemItemPageCurl