Issue using UITextField with long string - iphone

So currntly I have multiple UITextFields whose data is automatically inputted for the user when the app launches, mainly gets the location of the user and inputs them into the textfields.
Now, the issue is, when the textfields are filled, the textfields expand in width with respect to how much text is in the body of the UITextFields.
Heres a few pics of what really is going on, I'm also using nib files to create the layout, the left pic is of the application not getting an address inputted into the UITextfield from CLGeocoder coordinates, whereas the right view shows the UITextfield getting address string from the CLGeocoder.
I also notice that when I finish typing in a field, the fields EXPAND after I press return and the keyboard is dismissed.
I'm sure there is probably a setting in the nib file I uncheck or maybe I have to do this programatically? By instantiating the UITextfields programatically i mean.

As Rocky has already said, the problem is with auto-layout option of iOS 6.0. I also ran into this painful thing a while back. Turn off Auto-layout but now you will have to maintain two storyboards, one for iPhone 5 and there other for iPhone 4 and lower. Fun isn't it?

If you still decide to use auto-layout, make sure there are no User Constraints on the UITextFields where the Width is set to "Greater Than or Equal". This will allow the control to expand based on the content. If there are, just delete them.

Related

how to detect a password text field when running in the background?

I am developing a screen recorder and facing a crazy requirement. My boss would like to have an option for a user to automatically pause recording when the current view has a password field. (That view might belong to a third-party app.)
So, is it possible to check if the topmost view has any password text field?
This is an enterprise app so private api is allowed.
Any pointer from jailbreak community is also welcome.
It would be much easier if you could just use your own views but this should work for either your own views or a third party view. BUt anyway, every time you would load up a UIView check all of its subviews, in the ViewDidLoad Method i would think and for each subview check for its class type in your case it would be UITextField. Since these are the only textfields where you can set secure text entry as its text type. Every time you find a UITExtView check if its secureTextEntry is equal to TRUE. If it is true disable the recording until that view is removed from the screen. That should be what you need.

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.

How do I make an editable detail view on the iPhone with a grouped UITableView?

I want to make a grouped TableView similar to the Apple iPhone contacts application.
I need a lot of standard fields which can be edited, but I would only like them editable once the edit button in the navbar is clicked.
This has been bothering me forever that I could not find a good tutorial.
Thanks in advance.
This is not easy. I just built the same thing because there is nothing available from Apple. I ended up creating a single table cell with a UILabel and a UIView on it. The UILabel is for when the cell is in read mode, and the UIView is for editing. The UIView contains a number of UITextFields. These are the individual fields. I also had to implement drawing code to draw the lines between the fields. Then I had to come up with the code to pass in an address object, load it into the fields, format the text for the label, switch in and out of editing mode (with animation), and finally handling saving of changes and canceling. As yet it doesn't handle tapping the address type to select that from a popup list, but I have most of the code in place for the rest.
This could have been done using individual table view cells for each field. But then you can't select the whole thing the way it does in contacts and adding and deleting addresses becomes trickier.

Achieving dynamically growing TextView inside UITableView

I am working on fitting a UITextView inside a UITableView. My table is grouped style with only one section and one row. I've looked through various previous questions but I am unable to get this idea working. I want the result to be the same as the "notes" section in the Calendar app on iPad. And Apple has done the same thing in the contacts app as well for notes. Do I need to use view animations to make the tableView row keep growing dynamically as and when more and more text is typed into the textView? What is the correct overall approach to make this idea work? Any pointers would be greatly appreciated. I get the points on how to resize the textview depending on text size and how to modify the height of the table row. But how do I make these work together to give it a dynamic animated feel like in the Apple apps?
Also another thing I noticed is that the cursor always lands at the beginning of the text view due to which the text gets overwritten and ugly on appending. Is there any method to get the cursor to go to next to the last character in the textview when I tap on it again while some text already exists inside it?
Thanks
You can refer to this Post for dynamically growing your uitableviewcell.
This library can help you grow UITextView with auto layout
https://github.com/MatejBalantic/MBAutoGrowingTextView
You can set-up the hooks (either in the library or you set-up the UITextView delegate) to make sure size of the table view cell get's recalculated based on the new UITextView size each time content of the text view is changed.

textFieldShouldBeginEditing: Being Called Multiple Times for UITextField in UITableViewCell

This is an iPad app so it is based on SDK 3.2 (behavior also appears on later iOS release).
I created a custom UITableView cell class which contains a UITextField. The class for the cell adheres to the UITextFieldDelegate protocol and I've implemented the textFieldShouldBeginEditing method to intercept user interaction with the text field.
Everything usually works great but I've noticed that when the user scrolls the tableview and then taps on a field the textFieldShouldBeginEditing is called multiple times, sometimes on two different fields. This leads to users tapping on the field in one row of the table and a field in another row becoming first responder.
Has anyone encountered this behavior?
I'm working on a solution to set a flag to ignore input for a fixed time period but I really hate to do this and would love to know if there is a batter way.
I figured this out. I was reloading the tableview data at the same time as scrolling and it must have been recreating the text fields.
I changed to reloading single lines as I should have been doing anyways and it is working smoothly.