Strange entanglement between two UITableViews in XCode5 - ios

SUMMARY BEFORE EXPLANATION
It’s as if the storyboard is treating the Tables as pointers to a single instance, simply because I copied and pasted through the storyboard. I am recording this here in part as a reminder to myself (I am an avid user of Stack Overflow) and as a warning to others. And of course, I want to know if there is a simple way of truly disentangling the two without having to recreate one of the ViewControllers from scratch. please, read on for explanation.
BACK STORY
First I created CatUIViewController using the storyboard. I completed the whole thing along with .h and .m files. Then, needing a similar ViewController for Dogs, I dragged and dropped an empty ViewController onto the storyboard from Object Library, and then I copied and pasted the entire UITableView from CatUIViewController to DogUIViewController. Then of course I did the same with the .h and .m files. Really the only difference between CatUIViewController and DogUIViewController is that Cat has two buttons in it’s header while dog has an UIImageView, along with other data that both headers share.
Naturally, Xcode does all the connections for me the moment I pasted into the Dog equivalents. It wired all the IBOutlets and IBActions automatically: a nice feature of Xcode.
FURTHER DETAIL
Both table views have a background image. And navigation from Cat to Dog is possible because my app is using UITabBar — no other linking exists between the two. Furthermore, while Cat leads its Tab, Dog is way down the line in its Tab’s NavigationController.
THE PROBLEM
The problem is this: If I am in DogUIViewController and click the tab to transition to CatUIViewController, after the transition the background of DogUIViewController shows up as the background of CatUIViewController. In fact, if I visit DogUIViewController and then navigate to any other page so ever… the second I click on the Tab for CatUIViewController, mysteriously it first shows the data for DogUIViewController before switching to the correct data about 1 second later. Another strangeness is that the converse is equally true.
I have been investigating the code to see what might be the cause and so far I have found nothing. It’s as if the entanglement is happening at a layer in Xcode that is not exposed to me: I review the Connections Inspector, the .h and .m files and I cannot find anything so far. I am hoping it is a simple oversight on my part so I keep digging. But just in case it is not and someone else has resolved something similar, I am here asking.

Whereas you copied and pasted not only the UITableView but also both the .h and the .m file, the possibility for errors abounds. But of particular interest to me is that you mention differences to exist exclusively in the header files. This to me means the likely cause of errors is your data source. Wherever you are fetching the data, it takes a split second so that the new data is delayed just enough for the old data to show up. So I am ending my response with a question: How are you fetching your data? Are you caching the data? Are you cleaning property? For example, if you are using notification for the server to update your view controllers, viewDidUnload is deprecated so I wouldn't use that to unregister notificatoins. In whatever the case, you at your data source.

Related

UIScrollView multiple page confusion

So I have an existing app I'm working on for a friend...
and let's say I double click on animals_real and I get this screen...
Basically all I want to do is create a back button back to the home page on the animals_real page and all the other ones like it(body_parts_real, cleaning_real, etc.) but for whatever reason I can't find the xib file or the code for it and I'm not entirely sure what file it would be in. Also, since I am fairly new I'm not entirely sure how to implement the back button. Any help is greatly appreciated.
----------------------------------EDIT 1------------------------------------------
The main page works under ViewControllerForIphone.xib and the settings page is under SettingViewControllerIphone.xib. This led me to believe that the other pages would be under the SubPECSViewController_iPhone.xib. However, if I go in and edit that it doesn't change anything when I run the simulator. So, basically I have been trying to understand UIScrollView better and how it works but I am kind of just stuck.
Welcome to iOS. Other commenters will point out that you should start here at the UICollectionViewDelegate Reference (which you can also get to through Xcode (shift+command+0)
Basically, a uicollection view populates itself based on some array of data.Look here to see what's going on
(void)insertItemsAtIndexPaths:(NSArray *)indexPaths
When you tap on animals, this method is called:
– collectionView:didSelectItemAtIndexPath:
Some logic happens here, and I'm presuming you load the collectionview from yet another array.
To solve your original problem of a "back button," you might simply want to reload the viewcontroller's original datasource or possibly "pop" back up the navigation stack. Again, without seeing at least part of the code, there's very little we can do except speculate :)

IOS Why can't I drag connections from Storyboard elements to their respective ViewController?

I'm revising my app so that the first scene is a Standard ViewController containing a UITableView and a UIButton. This replaces the original UITableViewController.
Problem is, I can't (Control or Right-Click) drag from these elements to set outlets or actions in the associated ViewController class file.
I've checked and rechecked to be sure the identity of the VC is correctly set to the appropriate VC custom class file, but still no success.
I wonder if it may have to do with the fact that I deleted (trashed) the original UITableViewController and class files, although the .h file continued to show up in the Custom Class list under the Identity section for a while. It appears to be gone now.
I've cleaned and rebuilt several times, and quit and restarted Xcode, but without success.
Can anyone lend a hand?
Thanks!
Edit: Pursuant to a response to a similar question on SO, I checked the name of the ViewController class file by looking at the Storyboard as Source Code. The ViewController is in fact named correctly.

When I transfer from my master view to my detail view after adding a new item, my detail view is empty

I'm making a sample app to learn iOS dev, and I have the app create default items to populate the tableview originally, and you can add further ones as well.
If I tap on the default ones (well, there's only one) and segue to the detail view it shows all the details (Name, Location and Date) as intended. But if I add a new one, it comes up with those fields being Empty.
I can't figure out why. I have seemingly all the view refreshing methods set, and it should be setting the detail view's data object which then feeds the labels.
Could anyone help? I'd supply further code if requested, I just don't know what to supply now as I'm not sure exactly where the problem is. It's a rather simple app, though.
Project available here: http://cl.ly/3N0o272M3y1K
Ok this took a bit longer than planned - but it is a good way to learn.
I have attached the project in a zip file.
The code is a bit different then what you posted, but if you compare them side by side, you will see how they are planned and build differently.
It shows the Segue working within the Storyboard.
There where 2 big problems with your project outside of your misuses of the methods.
You need something like Core Data if you want your data to be persistant. In the example I have given you I have used Plist, this will do the trick, but is not persistant in this case.
Also your detailViewController had no labels for the text to appear, so you will need to look into Custom Cells for that - to match your design.
Good Luck and I hope this is useful:-)
Updated Project

iOS UIViewController trouble opening another uivewcontoller

I have two view controllers, one is main and second is detail. Whenever I click on one cell of uitableview in the main view controller, it should immediately show detail view controllers that has either empty cells or cells of some content in a uitableview. My codes work perfectly in one of my apps. However, when I copied whole codes and adapted the file names, nothing works, i.e. it does not present detail view controller, even though the debugger console showed it SHOULD work.
What could cause this trouble?
Did you use the "Refactor" option to rename the files, if not try refactoring the files from a fresh copy of your old project. Please post more info "nothing works" is a little too vague.
I solved it by copying the content of the files that feed my table view into new files with new names.

UINavigationController with in UITabBarNavigationController doesn't load the table data

Im extremely new to IOS.
I have a UITabBarNavigationController inside it I have an UINavigationController
I have a problem, The UINavigationController Doesn't load the table values (as in i have put all the methods and stuff for the datasource and mapped it in IB but it still doesn't seem to work)
For code click here
PS : When you run the project it will ask you for a username and a password please enter user1 for both.
Thanks for your help.
There's really a lot of stuff I would notify you about, man. But to be closer to your very question (I explored only the first tab, the others should be resolved in a similar way):
You have warnings in the interface builder. Maybe in the code in some cases you can ignore them, but not in IB. I corrected it and (not just after that) it worked (leave your email in comment if you want me send it to you). But I would advise you to spend 20 mins on watching
this video.
The code which initializes your tableView works before the user is even logged in (so that it's being initialized with nothing), therefore, even if all the rest of code is working, you will see the items in your tableView only after you reinitialize your tableView (e.g. change the tab and go back to your first one "Appointment" tab).
In the class AppointmentTable move your code from viewDidLoad to viewWillAppear or viewDidAppear (the last ones work every time you show your tab on the screen).
P.S. Leave your email in comment so I could send you corrected (not fully of course, but only in the places I pointed out) version of your project.

Resources