How to make buttons on UIAlertView displaying in multiple lines? - ios

I want to display a message using UIAlertView and there will be two buttons. As one of the buttons has a long name, It's not appropriate to display both of them in one line. I know that when there are more than two buttons, all of them will be displayed each in a row. How can I display these two buttons in two line?
Thanks.

There is no officially documented way to do this.
UIAlertView is a subclass of UIView. So you could traverse its subclasses to find the buttons, and transform their position and size. This is probably a bad idea though. If Apple changes it's implementation of the UIAlertView, it might break your code. Your app might also be rejected for customizing the UIAlertView. Eg see this answer.
Instead, you should consider changing the title of your button to be shorter, or create your custom UIView subclass that you present modally.

Related

Alt Button On Custom Keyboard in xCode

It's the first time I'm creating a keyboard for iOS. I've created the first page with all the buttons but I don't understand how to add the second page.
For example: first page QWERTY, second page 123.
Is here anyone that can explain all the passages and functions/classes that I have to add on my codes and where precisely?
Thanks a lot
Well I haven't built a custom keyboard personally but I would make seperate views for the "pages" of keyboards and just hide away and unhide the view of the keyboard you want to show when the user presses the "alt" button. You could have as many keyboards as you like with this method and have it pre-built in the backround so that it would function very quickly to swap between them. Or animate them as you like really as views are easy to slide around. Actually sounds like a lot of fun as I have often thought about building a keyboard that has alpha-numeric values all in one, which would make filling in details on a login screen much quicker/more convenient.

Can I use multiple lines of text in a UIAlertView's button?

At one point in my app, the user has to choose from a list of reasons (it's a medical app that lets one user check if another user gives a patient the right medicine and dose via one or more photos). If the photo is rejected, the user has to choose a reason.
One of our customers provided a list of possible reasons, and they can't be changed. The problem is that one of these reasons is a very long sentence and when I add it to the alertview, the text gets really small instead of just wrapping to a new line. I tried putting a \n in my string, but then the second line isn't shown (so it does work, but I only see the first line in the view).
Can I add multiline functionality to the alertview's buttons? I know a UIButton does not support multiline. I also know UIAlertView's addSubView: does not work anymore since iOS7. I'd rather not use any third party libraries, but if I really have to I'm open to suggestions. Increasing the size of the alertview would be an option as well.
For your requirement it will be better if you use UIActionSheet or Customized PopUp View where you can use multiline.
UIAlertView and UIActionSheet are really meant to provide concise feedback and make concise decisions respectively. It sounds like you need a richer interface for the user to make a selection. I would suggest that you create a custom UITableViewController class with a dynamic cell that presents a set of reasons and allows selection of a reason. You could dynamically create a non-editable UITextView to display a multi-line reason and perhaps a button next to the reason to select it. Each row of the UITableView would contain a UIButton to select and a UITextView to show the reason. In your UIableViewController class you would assemble all the reasons relative to the context and then present them in the table view for selection - one row for each possible response. Alternatively, you can forgo the button and just present the reasons via a UITextView. If the user clicks on the row (table cell) you can indicate the response with a check mark
cell.accessoryType = UITableViewCellAccessoryCheckmark;
and capture the selection for processing in
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Reason *selectedReason = self.myReasonsArray[indexPath.row];
}
enter link description here
Also, UIAlertViews do not support subclassing and have very limited configuration capabilities. I'm suggesting you accomplish your objective by creating a "custom" modal view via a UITableViewController that can be used to essentially popup a rich interface that allows you to do all sorts of things like have multi-line text, images, whatever. You can reuse this view everywhere via delegation.

Custom UIPicker control IOS

im looking for a similar control to this Android Wheel, its very similar to UIPickerView, but i know that Apple use to reject APPs that modify UIPickerView appearance.
I need a control that let me put images on a infinite loop scroll and let the user drag to select one.
I've found some controls here, but most of them only support strings, some support images and are looped but dont let the user scroll.
My purpose is to make a button scroll loop where you can drag any button to the center of the wheel and see a text description on a uilabel, i dont need the buttons to be clickables.
I hope I explained well, and sorry for my bad english.
I would better suggest you to go with the iCarousel here. This enables you a different mode of scrolling & directions & effects which you can project on a Custom view similar (by Sliding-In & Sliding-Out from the bottom of screen) like a UIPickerView. This is not at all made using extending UIPickerView, but you can project it like that. Once you see a demo app of it, you can eventually change your mind to use this over custom UIPickerView.
Just implement the delegate method declared here to know which of the element was clicked. iCarousel comes with a image loading view also. You can look into that too.
But if you want to stick with UIPickerView customization, then please have a look at this stack Overflow post. This is certainly what you want, except that you need to add button instead of images.

Putting a UIPopvercontroller in a storyboard uicontainer view

I am writing a small iPad app using Storyboards. On the first screen the user will be presented with about 7 pieces of information to enter.
Several pieces of information are of the form "How important is X to you" with 5 or 6 possible answers, like "Extremely Important" and "Very Important" and so on.
I think the correct design pattern is to have a Button on the storyboard with the value on the button, and the user can change the value by tapping the button, and then I will present a list of values in a UIPopover in a ContainerView.
First, is this the best design pattern.
Second, can someone point me in the right direction for accomplishing this? I just can't seem to get the pieces to work.
I am thinking that maybe I do not need the Container View, just the UIPopover.
Any help would be greatly appreciated!
Bryan
I suggest using a UITableViewController in a popover. The table contains all the valid options in the appropriate order. When the user taps (selects) a row in the table, invoke a delegate method that passes the selected option, sets the button text, and dismisses the popover.

Implement auto-completion on iPad

Scenario: I have a list of medication (stored somewhere, let's say an NSArray).
There is a UITextField where a user can enter a medication to get more information about it (or whatever).
I want to suggest word completions while he is typing (but that is rather easy).
Where is the best place to show these suggestions? Since it's on the iPad i want it kinda like when you google and you get your suggestions right below the search bar. Is that possible on the iPad? A table that lays over the rest of the screen, placed below the text field? Like a pop up or something? I have never really used an iPad in my life before, therefore I don't know what the iOS way would be..
Edit: Something like this but connected to a textfield and not a button or whatever that thing is:
Edit: Or even better: Something like this but for iPad and not Android:
In my app I used a UITableView for displaying the suggestion.
I added the tableView above my UITextField. When there is no auto complete word found, I hide the tableView.
Please check my autocomplete implemetation.
Check out my control, MLPAutoCompleteTextField for iOS. It is a subclass of UITextField that does autocomplete.
The implementation is similar to what you are looking for in the second screenshot, and very customizable.

Resources