UINavigationController with in UITabBarNavigationController doesn't load the table data - uitableview

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.

Related

Unable to identify operative event or method in XCode

I need help identifying what piece of code is causing a bug in my app but having a hard time working it out.
So, my app is designed to display a detail screen for any row that is selected in the master table.
I have recently updated my app to use an NSFetchResultsController. The results are what I would expect except for one odd behaviour.
The new behaviour happens when I select a row in the master table, prior to the segue to the detail screen.
The table populates with all the data I would expect. But, on clicking any row in the table (other than the first one), each field in the row is set to the default values that appear in the storyboard.
The segue to the detail screen displays the expected details and the underlying database table is also correct.
I have a segue outlet action on the cell but no other method.
Despite placing breakpoints at various points in the code, I cannot identify which code section is triggering the setting of the row to the storyboard defaults.
I'd appreciate any steer that would help me work this out.
I posted my question as relative newbie to xCode. I've now discovered the profiling tools built into xCode and have been able to identify what's happening in my code with more confidence.

Strange entanglement between two UITableViews in XCode5

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.

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 :)

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

Relationships between File Owner, App Delegate, View Controller, etc

Based on the little that i know, I tried to put together the relationships usually seen as part of MainWindow xib.
How far off am i? Kindly correct and advise.
Almost. View controllers inherit from uiwindows in the class system. And you have to think of it more like a pie chart. Everything is equally important, some are just more equal than others. On the top of the pie chart is the app delegate. It's the master of the app. It can reach into a view or Controller and pull whatever it wants. Now on the left side is a view. It's the dumb little sycophant of the whole thing. It can only recieved instructions from itself, or from the app delegate, then act on those instructions. It should never pull from the app delegate (not never, but most always) and DEFINITELY should never screw around with a controller. Finally, controllers. They are the brains of the whole app. They can't show information on screen like a view, but they can think pretty well. Controllers give the orders in your app. They shouldn't really pull from the app delegate, but they can (again, rarely). There's an excellent lecture from Standford or MIT (I'm forgetting now) in iTunes U about it. Look it up.

Resources