What are good alternatives to UIPicker? - cocoa-touch

I am working on a basic ordering UIViewController using the AQGridView to display multiple columns of products so I can use as much space as possible. For the time being I implemented UITextFields to enter the quantities for each product.
I am trying to find an alternative to UIPicker, some sort of dropdown. The fact that both, the entering text directly to the UITextField and the UIPicker bring up either the keyboard in the case of the UITextField or simply occupies a big portion of the screen from the start for the UIPicker.
Does anyone know of any alternatives to use? Or if there is a way to have a tiny UIPicker just on the cell for each product?
I guess I can simply play around with the individual cell and add the UIPicker with given CGRect. The thing is that it will still occupy quite some space.

Pickers are always the same size as the keyboard. Don't try to force a picker into a smaller space -- they look terrible when they're compressed, and that's like adding a note to the app store reviewers that says "Please reject my application."

Related

UTextView autocomplete vs live suggestions iOS

If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?
This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.
In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.

Editable text inside UISegmentedController

I want to have a UISegmentedController but the user can choose the segment and change the text inside. Is there any way to do that?
Thanks.
EDIT: This is what I would like to do. I have users which choose an option using UISegmentedControl. Under settings, I would like to give them the opportunity to modify what the texts in the UISegmentedControl is. I can use a UITextField and a button which triggers the change but I didn't like that solution. I considered putting a UISegmentedControl image with UITextField inside each segment but that does not seem like an elegant solution. Besides, I have no idea what the font is being used in UISegmentedControl. If I am not mistaken, by default, you can only fit a maximum of 12/13 chars or else it can break. iOS 5 SDK has some more methods to customize so it may be possible.
I coded a solution which involves a preview of what the UISegmentedControl will look like, 2 textfields to replace the texts inside each segment and a button which saves the value. I scraped it because I did not like the implementation and I just didn't like the execution too. I wanted the users to feel like they are using the UISegmentedControl and able to edit the texts inside it, up to a max of 12/13 chars.
Thanks.
You can always dynamically change the values of the segmented controller in code. Would it be acceptable to have the user click the button, at which point you could pop up a form for the user to fill in with the new value, and then call this method on the segmented control:
- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment

iOS dynamically filling search results

I am building a small Search app on iPad. I want to show the search results. Do I use UIScrollView or UITableView?
The number of search results are unknown & as the user scrolls vertically I'll want to dynamically keep fetching the results & fill whatever container I will be using. Something like what Google Reader (on web) has.
For this purpose which is better suited? UIScrollView or UITableView? Also please guide me as to how dynamically populate the results?
This is an awesome question. I have a different approach for a solution to this problem. It is not the exact answer; But I would assume that the logic might be helpful -
Algorithm:
Decide on a certain number of records being pulled into the UITableView. (lets say 8 ).
You can use a UIScrollView with a small size (rather than setting it with smaller stepping size & frame).
Using the clipsToBounds property (set it to NO), you can actually track the amount of scroll, and check if it goes out of bounds
After you go beyond the bounds, initialize a new UIScrollView with a fresh-list of tables, and get another 8 data entries, and this can be continued.
Reduce the size, set the property and it would work.
But the problem with this is that ; if you try to touch outside the scrolling area => it will not scroll up/down.
Please refer to this tutorial, which can offer some intel on this idea.
And for setting the Scroll amount for Page control => Refer to this question on Stack Overflow.

iOS Longpress to select text

I am building a simple table based search app. The user can ofcourse search through keyboard. But I also want to have another mode of search.
Say a user longpress on a UILabel then based on where the press is happening, that word should get selected & search should happen (no keyboard) on that word.
I know how to detect longpress events but does anyone know how to copy, detect & access the exact term where the longpress has occurred?
UPDATE: I am aware that I can get the object where longpress occurred from which I can get the content of the label text. But I need the exact word on top of which the finger was placed.
Nothing easy comes to mind for UILabel or UITextView. If you're wiling to lay the text out yourself with Core Text, then you can pretty easily find words near the touch. The trouble with that is you'd lose the existing selection features of UILabel and have to reimplement them (or do "shadow layout" in Core Text hoping things will lay out identically in the UILabel... slowly descending into madness here.)
Rather than going down this rabbit hole, I'd recommend using the standard text selection mechanism and add "search" to the menu.
Just put a UILongPressGestureRecognizer on your label then when the gesture recognizer fires you can access which object it came from and read the label value from there.
myLongPressRecognizer.view

Customising UITableView scrolling!

Is it possible to make the table view allow scrolling only in one section and not others OR in other words allowing scrolling only in desired sections of the grouped table?
Many thanks.
Sure, this is entirely possible if you're willing to forego the use of a tableview. If you use a scrollview, you can achieve what you want by defining custom behaviour. It's not going to be easy but here are some suggestions:
Figure out how you want it laid out on the screen
Create a "floating cell" that will hang around, this will be your "not scrolling" section
With respect to #2 above, you'll have to figure out what kind of logic you want to make that floating cell disappear versus the other data.
The rest, you're effectively reimplementing a tableview.
Now, you can probably achieve this with a tableview, but it's be hairy big time.