This is going to be hard to demonstrate in code, but maybe you can picture it with me.
I have a view that contains two UITextFields, "title" and "descr". That same view contains two UIButtons that push another controller onto the navController to get more detail from the user about the object we're assembling and ultimately uploading to my server.
It appears that pushing another view on, doing something, and popping it back off results in the two UITextFields keeping their content VISUALLY, but the .text property of those fields becomes NULL. I've confirmed that if I do my two push-pop fields before filling in those UITextFields, I get my data when I upload, and if I do them in the opposite order, I don't. It LOOKS like there's data there, but I get nothing when I NSLog their .text properties.
Is this normal? Do I need to just design around this? Or is this as weird as it seems, and I should be looking deeper at causes of this?
I bet that you loose the references to the text fields.
Try to check 2 things:
Check if you have anything except the text (e.g. color, font, text alignment) - maybe the text view are nil
Try to write something into the text fields after the push-pop and then see if you have the .text property
Took me a while to get back to that (my BIG stack of bugs is getting ever smaller as release date approaches!), but I figured it out. On viewWillAppear, I was doing a reloadData on the table that these fields were in, and that was resetting my form fields. I stashed my data before that reloadData call and re-populated them in the tableView:cellForRowAtIndexPath: method, and we're golden.
Related
It is so lucky to find the michaeltyson/TPKeyboardAvoiding to solve the Keyboard blocking text field problem. The TPKeyboardAvoiding is very nice. User just needs defining custom class as TPKeyboardAvoiding to make it happen.
My Question and Problem is:
In my condition, I have two views include scroll view. In each scroll view, there are sevral text fields. One view segue to other view. After segued view's last text field been edited, the previous view can't scroll to the last text filed.
All in all, after user editing one scroll view, the other view's content insets -> bottom value changed! Anyone has similar experience with me?
Correct one
Wrong one
My unsuccessful try: I have tried copy another paire of TPKeyboardAvoidingScrollView.h & .m file into project, and renamed them.It doesn't work.
BTW, even the segued view can't raise last textfield up entirely.
I have not used TPKeyboardAvoid with two Scroll views but sometime using alternate framework might solve your problem :
You can give try to following frameworks -
https://github.com/muanis/sampleapps_scrollview
https://github.com/kirpichenko/EKKeyboardAvoiding
https://github.com/freerunnering/SwipeSelection
https://github.com/rnystrom/RNAvatarLogin
https://github.com/lupidan/UIKeyboardCoView
I have a generic question about tableview Draw and reload data, and wanted some insight from this scenario. I have a tableView which get's lazily loaded getting the data parsed from a url. Now the concern is when i select a button and move to another view, I can deselect the object from there, which will remove it from the array. Thus, when I go back to the main view of the tableView, it download's the data again and check's if the object of the further view array is there or not, therefore it set it selected the button.
My concern is, when I go back, my previous selected button is highlighted, and then it does all the computation and de-selects it when the data gets loaded. Is there anyway, I can have the tableView redrawn until the data load's everytime?
Thanks.
It Looks like that when you are downloading the data & parsing the downloaded data, you are directly passing the modified variable as a source for the tableview. Instead of it, You may store the source for the tableview into another array, which will get updated from source array if it is downloaded & parsed.
Load the tableview using the secondary array.
This is my understanding. If your problem is not resolved , please provide some piece of code for the problem.
BTW, your problem can be resolved using the above solution.
This is the situation:
A user filters a database by selecting keywords from a list, then presses "search". This pushes an instance of a UITableViewController subclass onto the navigation stack.
In the viewWillAppear: method, data are fetched from Core Data and stored in an ivar, ready for the table view's data source and delegate methods.
So far so good.
The UI problem arises when there are no results.
This simple architecture means that an empty result set yields an empty table view with no explanations.
It would be good for the UI to tell the user something like "Your search gave no results, please try with fewer keywords".
My question is this:
What is the best way to provide relevant feedback to the user, without having to change the architecture too much?
I was thinking about using the table header, but what do my esteemed colleagues here think?
Using the table header is not a bad option. You can go for that. You can also try other options like showing the info in a simple label or perhaps even an alert. But personally I wouldnt recommend the alert.
U can show that in UIAlertView.
You could add / show a UILabel to your view that says "No search results" (or something like that) when the table does not contain any data.
After fetching the result from core data... just count the number of rows in the result and then before displaying Table View just check if Count>0 then only go for table view ... else just display UIAlertView... this will save u from unnecessary display of UITableView
You can put AlertView when your ivar is empty and in alert button index return to the main view from where you are entering your search. This is the best way for you without changing your architecture.
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.
I have a multi-section UITableView with custom header views that need to know their section index. I currently record the section number in the tag field of UIView when creating the custom view in viewForHeaderInSection. However, when a row is deleted, the UITableView does not reload the section header views for header views visible on the screen, so their tag fields become out of sync. Calling reloadData on the table re-syncs the tag fields by recreating the header views, but calling reloadData interferes with the row deletion animation. Setting up a timer to call reloadData after a "short" period of time seems hacky and somewhat risky if the user ends up interacting with an out-of-sync header before the timer fires (I suppose I could add a state variable to prevent this, ugh).
I could I suppose keep track of all header views created in a container, and adjust their tags when rows are deleted (ugh again). But then how do I avoid leaking the Views? How do I know when the UITableView has released the view so I can delete my reference to them so they can be released?
This seems like way more work than it should be....am I missing something? I've noticed others have very similar issues and never seen a definitive approach to solving it.
I have a multi-section UITableView with custom header views that need to know their section index. I currently record the section number in the tag field of UIView when creating the custom view in viewForHeaderInSection.
How about a dictionary owned by the controller that records each section number for each view. Since you have the recorded section number dependent on the tableview you have to wait for it to refresh (which you shouldn't have to call often yourself.)
You just have to find/make a way to have keys for each view so you know which one is which regardless of the order.
Setting up a timer to call reloadData after a "short" period of time seems hacky and somewhat risky if the user ends up interacting with an out-of-sync header before the timer fires (I suppose I could add a state variable to prevent this, ugh).
I agree that it seems hacky, good instinct. Adding a state variable to prevent this would be less work than a dictionary and tracking system for each view, but I think it would also fall under 'hacky solutions'.
You shouldn't need to reload the table; just update the tag property. In your code where you delete the rows; do you have access to the header views? If not, you can use the observing pattern to alert the header views when a row has been deleted.