Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

isthisonetaken

macrumors regular
Original poster
Jun 29, 2006
123
0
Hey GUys,

so I'm trying to use iOS 5's new API's for containing children view controllers in a parent view. I got it working for simply UIViewControllers but I'm having some issues with a UITableViewController to show up properly.

In my storyboard I have a UIViewController which is my parent view controller. It has a UIView with an outlet hooked up where I want the child UITableViewController to go. I also have a separate scene which is a UITableViewController embedded in a navigation controller. In my viewDidLoad method in the Parent I call this code:

Code:
    ChargesTableViewController *chargesController = [storyboard instantiateViewControllerWithIdentifier:@"ChargesScene"];
    chargesController.view.frame = self.chargesView.bounds;
    self.chargesView.layer.cornerRadius = 15.0;
    self.chargesView.layer.masksToBounds = YES;

    [self.chargesView addSubview:chargesController.view];
    [chargesController didMoveToParentViewController:self];
    [self addChildViewController:chargesController];

It shows the table view (currently empty) and can be scrolled, but it doesn't show me the Navigation Bar which has an Add button on it for adding new charges.

The functionality I'm looking to accomplish is to display a bunch of charges in the table view and somehow allow the user to add a new charge. I can't add a UIToolBar to the UITableViewController, so I thought if I embedded the view controller in a nav controller, it would let me see and use the nab bar, but it's not...

Any ideas how to either fix this or add the functionality I'm looking for?

Thanks
 
Hey GUys,

so I'm trying to use iOS 5's new API's for containing children view controllers in a parent view. I got it working for simply UIViewControllers but I'm having some issues with a UITableViewController to show up properly.

In my storyboard I have a UIViewController which is my parent view controller. It has a UIView with an outlet hooked up where I want the child UITableViewController to go. I also have a separate scene which is a UITableViewController embedded in a navigation controller. In my viewDidLoad method in the Parent I call this code:

Code:
    ChargesTableViewController *chargesController = [storyboard instantiateViewControllerWithIdentifier:@"ChargesScene"];
    chargesController.view.frame = self.chargesView.bounds;
    self.chargesView.layer.cornerRadius = 15.0;
    self.chargesView.layer.masksToBounds = YES;

    [self.chargesView addSubview:chargesController.view];
    [chargesController didMoveToParentViewController:self];
    [self addChildViewController:chargesController];

It shows the table view (currently empty) and can be scrolled, but it doesn't show me the Navigation Bar which has an Add button on it for adding new charges.

The functionality I'm looking to accomplish is to display a bunch of charges in the table view and somehow allow the user to add a new charge. I can't add a UIToolBar to the UITableViewController, so I thought if I embedded the view controller in a nav controller, it would let me see and use the nab bar, but it's not...

Any ideas how to either fix this or add the functionality I'm looking for?

Thanks

To do what you want you'll have to add the NavigationController's view rather than the ChargesController's. I suspect this might get tricky though, I seem to remember having problems when I tried to do something like this in the path. Th UInavigationController kind of expects to be in some sort of hierarchy of controllers, and might not play nicely by having its view shoved into another view.
 
To do what you want you'll have to add the NavigationController's view rather than the ChargesController's. I suspect this might get tricky though, I seem to remember having problems when I tried to do something like this in the path. Th UInavigationController kind of expects to be in some sort of hierarchy of controllers, and might not play nicely by having its view shoved into another view.

The only reason I had the nab bar was to be able to have an 'Add' button. Is there some other way to allow the user to Add new content to the table if I can't have access to a nab bar or tool bar? Can I have a button in the parent view and pass a message onto the child view when it is clicked?
 
The only reason I had the nab bar was to be able to have an 'Add' button. Is there some other way to allow the user to Add new content to the table if I can't have access to a nab bar or tool bar? Can I have a button in the parent view and pass a message onto the child view when it is clicked?

Only responding to your last post here.
You don't need the nav bar if you're not using it's functionality, you can also just add a Tabbar, and put buttons on there.
If you don't have acces, you should maybe do it like you described in your last sentence, have a button in your parent view controller, and send a delegate message, or send it via NSNotificationCenter, and pass the object with it..
There are alot of possibilities :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.