Re-usable views or xibs for use with UIStoryboard - xcode

I find it very convenient to use storyboards, especially to have (and show) an overview of the application.
However, I also find it very annoying to replicate the same code and views without the possibility to keep at least a reusable library of the most common xibs.
This is especially true with UITableView and its cell.
Did some of you have had any idea or best practice to share for dealing with this issue?

I was just looking at this yesterday, and it doesn't appear to be possible just yet. I've decided to go for the good old nib in case I want to be able to reuse a view. You can still use them while your main UI is defined in a storyboard using
UIView *view = [[NSBundle mainbundle] loadNibNamed:#"Nibfile" owner:self options:nil];

I tried this for about two weeks when finally discovery that you have to define if you will work with storyboard or xib files. They aren't going to work together.
I think that is sad too, but until the moment, there's nothing to do about it. The storyboard don't call your xib files and the segues will not work too.

According to several other posts - search storyboard and xib - people are currently using xibs and storyboards together, where xibs can be used to handle re-usable views. When you create a new file -> iOS -> View or Window, xcode creates a xib for you.

Related

CoreData ArrayControllers in Cocoa Storyboards

I am developing the Mac OS port of an iOS App and do face a problem with NSManagedObjectContexts when using NSArrayControllers in the Storyboard based Cocoa app.
It's kind of a follow-up question to:
Storyboard with TabViewController in OS X Application - Core Data Array Controllers in each scene?
I do have some ViewControllers presented like in a TabBarController, showing the same CoreData Entities. They are loaded through NSArrayControllers, that are hooked up with InterfaceBuilder.
From my existing knowledge, it was no problem to get the data on the screens. Even editing and saving to CoreData works.
But I realized, that every Storyboard scene got it's own instance of the NSArrayControllers and each its own NSManagedObjectContext.
When changing and saving the data on one screen, it is NOT updated on the other screens, that are all bound through the IB bindings and work in all other cases. They are just showing the data, they have loaded initially and are not updating automatically.
I think the problem is, that the changed data from contextA is not merged (or synced) to the other contexts of the other screens.
What is the best way of doing that? Should I use the NSManagedObjectContextDidSaveNotification for this?
That would mean, I would have to write much code, to manually start merging the changes from one context to all the other NSManagedContexts. Does smell really bad to me. I think there must be a much easier way, that I am not aware of and unable to find out about.
If you do have a hint for me, please just stick me in the right direction.
Thanks for that already.
Problem solved, I did a thumb error with Cocoa Bindings: I just dragged an object in the storyboard to every scene and set that to the AppDelegate. I just instantiated several AppDelegates with this, very bad idea! I corrected this, referencing the AppDelegate through properties on my ViewControllers and now it works as it should be. IB just has its little edges, where one has to be totally aware, about what is happening.

Showing views in interface builder outside viewcontroller hierarchy in xcode5

I often make use of views in interface builder that live outside of the viewcontroller hierarchy (see screen grab below for simple example).
Before upgrading to Xcode5 I could get this view to appear on the storyboard by writing an IBAction outlet and dragging a connection from the code to the view in the storyboard.
If you paused over the button for a moment it would flash and then open up as a view on the storyboard that is then a lot easier to work with.
Since upgrading this function no longer seems available. Has anyone found out how to get these views to appear on the storyboard?
Edit:
Using the temporary viewcontroller as described in this answer seems one approach, although fiddly since you need to move the UIView stack between viewcontrollers each time you want to edit the layout. Using a separate XIB is starting to seem like the sanest approach.
https://stackoverflow.com/a/13713385/1060154
Finally, we get this back in Xcode 7.
Hallelu!

How to manage efficiently ib in xcode for big projects

Can we use multiple separate views and integrate/call them on main view within a cocoa project?
Currently we are dropping all of our sub views and IB controls into a single view and making changes in IB is becoming unamageble now. When working on IB in xCode, it consumes 2.4 GB of memory. Please suggest a better strategy to organize IB views and controls.
Yes. Absolutely. There are lots of examples of using several nib or xib files together. I suggest you check out the sample code at developer.apple.com.

Xcode 4 and controllers with xibs

I have main xib with a splitview controller and ive dragged the ibactions and properties on to the AppDelegate code.
So in my applicationDidFinishLaunching i would like to load a controller which uses a xib into one of the nsviews that i have linked up.
The problem is that i can't use xcode to link ibactions and properties from the new xib into the controller that is going to load it.
Does that have to be done programatically?
I'm unsure of exactly what you are trying to do. However, it sounds like the 'splitview controller' you are referring to should be a subclass of NSViewController, then it can manage the xib for you.
Again, I'm not certain what you are trying to do; perhaps post a snippet of code?

How do I use multiple views in my iPad app?

I am trying to build an fairly simple iPad app that requires me to navigate through multiple views. What I want to do is have some sort of main menu view with multiple buttons on it, and when you click one of the buttons the new view appears and then you work with that. I'm new to iPad development, so I have a few questions about the best way to get this done.
1) If I build the views in Interface Builder, how do I make them aware of each other in Xcode? I can't seem to figure out what I need to do in order to code a button to say "Open View 'Foo'"
2) When I open the views, how should I be adding them in relation to the main menu view? Should I add the new view as a subview of the main menu view, or should I close the main menu view, open the new view, and then reopen the main menu upon closing the first view? I imagine both ways are possible, but are there any performance implications I should be aware of?
Thanks,
Mike
I'm making an assumption that it's more or less the same between iPhone and iPad. I haven't started iPad development yet.
You make view controllers aware of each other by importing their headers in your implementation files
FirstViewController.m
#import "SecondViewController.h"
If you're going for a navigation-style app, you should embed your top level view controller in a navigation controller, then you advance to the next one by calling
SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
//set any properties
[self.navigationController pushViewController:secondVC animated:YES];
[secondVC release];

Resources