Discarding picker iOS - iphone

Recently I've submitted an application to Apple and they told me that to show a UIPickerView in iPad I have to embed it into a Popover, so the discarding is as easy as touching outside of the Popover...
How I'm supposed to discard a UIPickerView with iPhone?
I don't want to push another view and then return to the initial view to make the selection because it would interrupt usability flow.
On my current implementation I'm showing the UIPickerView below the selection UITextField and discarding it with a UIButton... is this method correct?
Kind regards!

No, the correct method is precisely as Apple explained to you. You need to put the UIPickerView -INSIDE- a UIPopover. Below is a link to another question/answer that would be a good reference for you:
UIPopoverController too large and UIPickerView too small

Related

How to add more than eight buttons in a UIAlertView?

I want to add more than 8 buttons in UIAlertView but when I am adding buttons, they are covering each other and not scrolling. The title is also hiding.
How can I resolve this and add some scrolling in the alertview ??
Seems like this kind of question comes up at least once a day on StackOverflow, but if you want to mess around with the various components within a UIAlertView, the short answer is: DON'T.
If you look at Apple's documentation for UIAlertView, within the first screenful of text it states:
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.
This means that there's a decent chance that any mucking around within UIAlertView hierarchy could catastrophically break your app in future iOS release.
So if you want to add scroll bars or bells & whistles, you really should create your own custom UIView (which looks like a UIAlertView, but is wholly of your own creation)
If you have more buttons then UIActionSheet is the best option than using UIAlertView. If you dont want to use UIActionSheet there is always a custom View to your rescue!
You should really rethink your UI if you need more that 8 button in a UIAlertView. 8 button is the maximum the standard alert view can handle.
Either build your own alert view or use a normal view controller with a table view.
Not sure if it's necessary but as an alternative, you can present another ViewController/ModalVC that will have all the attributes that you may require....
Just move ahead with CustomView, Otherwise not possible with UIAlertView to meet up with your requirement :
Reference links :
http://iphonedevelopment.blogspot.in/2010/05/custom-alert-views.html
http://iosdevtricks.blogspot.in/2013/04/creating-custom-alert-view-for-iphone.html
https://stackoverflow.com/a/6965828/434898
If you want to add many buttons you can use a custom implementation for the alertView.
A nice example is FUIAlertView
Or you could use WEpopover and add to it a table view.

Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone)

I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have one UITableViewCell that contains a UITextView.
I have also implemented a UIToolbar that appears on top of the UIKeyboard that allows the user to move through the UITextField's by pressing previous or next.
The issue I'm having is two-fold:
I need the UITableView to scroll so that when the next UITextField (or UITextView) becomes the first responder it is visible (even with the keyboard being displayed).
When a UITextField (or UITextView) is selected (without using the previous and next buttons) is should adjust so that the field is visible above the keyboard.
I have looked around at lots of different tutorials however none of them have resolved my issue. Any help you could offer would be hugely appreciated.
ADDITIONAL INFO:
I'm 100% certain that my app used to do all of the above automatically, however I seems to have stopped doing it now and I don't understand why. Is there a reason why this may of happened? Is there some function or something that I may have changed that would destroy this behaviour?
Probably no use to original poster now, but those having an issue like this where it once did work and then stopped...
check you don't have a:
- (void)viewWillAppear:(BOOL)animated
in your UITableViewController subclass!!!
using viewWillAppear in a UITableViewController breaks the "automagic tableView scrolling up when keyboard appears" behaviour.
I only found this by comparing laboriously an old version of a project where it did work with my latest source where it had stopped working.
Check out TaggedLocations sample code from apple. It does the same thing without any extra manipulation.
The key is that your viewcontrollers are following the standard. i.e you are NOT having container viewcontrollers such as UINavigationController within UIViewController.
You have to update tableview Frame yourself programatically...
and i am 100% sure that if you are 100% certain that your app used to do all of the above automatically ...than it is not your app.
Check the docs..here is the link
https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-SW1
You will have to register for keyboard notifications..and then update your tableview frame.
And for next and previous.. you have to programmatically check which textfield became active..and then set the frame accordingly.

Non-modal iOS keypad interface

Is it known how to get the keypad interface from the Phone and Skype apps? This is distinct from the modal keypad view that appears when a UITextField becomes the first responder.
Is this just a UIView that the developers of Skype laid out themselves in IB, complete with custom graphics to get the square shape of each button? Or is there some standard Cocoa Touch way to do it?
This isn't something that Cocoa Touch provides out of the box, no. I would imagine that the iPhone keypad is a set of UIButton objects arranged like a keypad and using custom graphics to get the visual appearance. This should be fairly easy to do in Interface Builder.
You may be looking for UIKeyboardType in the protocol UITextInputTraits, which is implemented by UITextField etc.. See the documentation at that link.
I was getting confused by your question too. I'm not aware of any but seeing as you would need somewhere to type in anyway wouldn't it be better to make the UITextField active on viewWillAppear and turn off touches on the rest of the view hence showing the keypad like the phone app?

iPhone keyboard doesn't appear when entering a UITextField

This has to be some kind of newbie blunder that I just can’t see, and I’d be grateful for hints as to what to check or where to look.
I've followed an iPhone tutorial that has a UITextField, making sure I connected the IBOutlet for the text field, and it seems to compile properly (no errors or warnings). But when I run it under the simulator, and click in the field, I don’t get the keyboard, so I can’t enter anything into the field.
I’ve tried searching the site for similar questions, and all I’ve found is a few questions where the developer is trying to set up some complex UI with multiple controllers, and one that seemed to be the same issue, but the original poster simply said that he solved it by starting a new project and porting the code over. I’d like to find an actual solution, so I don’t have to try randomly rebuilding projects when this issue comes up again.
Thanks!
Just to cover all your bases when troubleshooting this, make sure it's not the iOS Simulator that's causing this. I wasn't seeing the keyboard appear when entering a UITextView as well and it turns out the simulator allows you to toggle between displaying the virtual keyboard and just having you use your laptop's keyboard.
You toggle between the two via:
Hardware > Keyboard > Toggle Software Keyboard
or press Cmd + K.
(my source: https://stackoverflow.com/a/24401535/1700540)
So make sure you didn't mistakenly toggle the simulator to only use your physical keyboard! ... like I had
Make sure parent containers have User Interaction Enabled checked. It is not sufficient for the individual controls to have this checked. The UIView can inadvertently get this deselected.
One thing you should check is to make sure the containing view (the UIView that contains all the controls), which is the View icon in Interface Builder nib viewer, has User Interaction Enabled checked. If the parent container doesn't have this checked, even if the individual controls do, you will see this behavior.
What is the delegate for the UITextField connected to? Have you made sure that the delegate functions, particularly - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
is returning the right thing (in this case YES)?
Not sure if this is anyone else's problem but I was using a TextField in a TabBar controller displayed modally and I added the shake gesture in my main view controller. This unfortunately meant I was setting [self becomeFirstResponder] in the viewDidLoad. In that case when my modal view displayed it was not becoming the first responder and hence the keyboard did not display.
To fix it I added [self resignFirstResponder] just prior to calling the modal display and all is well once more! Yay (only took five days to figure that out).
Basicly the only thing you need to do is declare the text field in the .h
IBOutlet UITextField *textField
then declare with same name in the property
#property (nonatomic, retain) UITextField *textField;
then make sure you synthesize in the .m
#synthesize textField;
then you have to link the field in the interface builder

Will Apple reject my app if I do not do this?

From the documentation of UITableView / UITableViewController:
If you decide to use a
UIViewController subclass rather than
a subclass of UITableViewController to
manage a table view, you should
perform a couple of the tasks
mentioned above to conform to the
human-interface guidelines.
To clear
any selection in the table view before
it’s displayed, implement the
viewWillAppear: method to clear the
selected row (if any) by calling
deselectRowAtIndexPath:animated:.
After the table view has been
displayed, you should flash the scroll
view’s scroll indicators by sending a
flashScrollIndicators message to the
table view; you can do this in an
override of the viewDidAppear: method
of UIViewController.
So lets say I do my custom stuff here and I do not flash the scroll indicator, and I do not reset the selection (which I think is wrong anyways, the user wants to know from where he came from). Will they reject it?
Apple may reject it. In practice, they won't (this is practical experience, not inside knowledge). They will reject apps now for using their private api, although in the past they wouldn't. But if your app sucks, not flashing scroll indicators might be a reason they give for rejecting it. If not deselecting a cell is important to your UX, then you should be ok - or it's possible that you have a poor UX.
Deselecting the cell should be animated - so the user gets the hint of where they came back from, which they should be able to remember anyway. But retaining the selection could lead the user to think that the selection is somehow significant and will affect their subsequent actions, which from your description it won't. So lose the selection.