iOS UIViewController trouble opening another uivewcontoller - ios

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.

Related

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.

Copy & Paste items from one view to another within storyboard without referencing outlets?

When I copy and paste, (cmd-c, cmd-v) items from one view to another in Storyboard it also copies and pastes the items referencing outlets.
Obviously, it's achievable by going in and deleting the referencing outlets one by one. Which is what I want to avoid.
I'm looking for something akin to (dare I say it) Excel's 'paste special' command.
UPDATE
Nope, doesn't work in xcode 5.1 either, see image below, hopefully it succinctly shows you what is going on.
The image shows a view at the top, Add Expense View Controller, another view at the bottom, the name's beside the point, I've copied my cells from Add Expense View Controller, lo & behold it's got the old references in there. You can also see I'm using xcode 5.1...
So - how do you, or is it simply not possible, copy and paste without these references?
Interestingly there is a paste special option in the Edit menu, but in Xcode's menu definitions in the documentation there is no definition for "Paste Special"...
Seems like they fixed it on Xcode 5.1. Both copy/paste and option+drag doesn't copy the referencing outlets.

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

copied a UITable to a other Storyboard, now I cannot see any rows?

copied a UITable to a other Storyboard, now I cannot see any rows ?
I Hade a nice looking and working Table with many rows linked to a nice View. Everything was perfect, Than I copy/paste the NavigationController, TableView and the corresponding View to a new project, I also imported the necessarily files (if I forgor someone, Xcode reminded me)
Running the new project code, works fine until I push in to the "old" tableView
nothing in the view is visible?
It might interesting to know that the title, and the addButton(upper right) EditButton(upper left) that I have in the TableView is there thou the addButton crasch the program. with the error mag something like "Invalid table view update" Im thinking that this has to do with my AppDelegate.hm ?
The new project have files called StartAppDelegate.hm
But all table info is in the "old" AppDelegate.m so maybe connect them in some way?
Am I on to something or just wasting my time?
I please you all to help if you have any idea, I guess this is some rookie mistake but I cannot find any info surfing around.
Thanks in advance!
Try setting Some attributes in Various Inspector of your View and TableView. There might be a Small mistak...

Hiding the Root View of a UISplitViewController

For the app that i am developing i have used a UISplitViewController as my base, but have modified, or attempting to modify the split view controller like that of Alice Bevan–McGregor's on http://vimeo.com/13054813. However in my app i have a table view with a list of options, and every time i click on an option it loads the corresponding detail page from a detached nib file. So, at the start of my app i can see and use the hidesidebar fine though it displays a white page. when i choose an option, the toolbar is overridden by the corresponding nib, so it dissapears. What i am not sure about is how to connect it in a way that it appears on every page(nib) everytime i choose an option from the tableview. I have been stuck with this problem for quite a while now.
essentially i would like the toolbar to maintain its functionality no matter what page i am on.
Anyone have any ideas?
May be you should give a try to this http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad
It has the following method
- (IBAction)toggleMasterView:(id)sender;
My own implementation of custom splitview using navigation based app # https://github.com/palaniraja/cUISplitViewController
Also try Salva's implementation http://iphone-dev-tips.alterplay.com/2011/05/custom-uisplitviewcontroller-for-ipad.html

Resources