UITableViewController static cells not appearing when pushed to navigationController - ios

I'm running into a rut...
I've create a UITableViewController with static cells (i've deleted all default UITableView methods). Whenever I segue to this view controller, the static cells appear, but when I push it onto the navigationcontroller the static cells do not appear...any idea to why this would be hapenning?
Here is my code:
//shows empty uitableviewcontroller
OthersUsersTableViewController *tvc = [[OthersUsersTableViewController alloc]init];
[self.navigationController pushViewController:tvc
animated:YES];
and
//works
[self performSegueWithIdentifier:#"toOtherUser" sender:self];
Thanks for the help!

If you manually alloc and init your Static table view, how should your app know that it is referencing a static table view in your storyboard?
Give your static table view an Identifier in the storyboard and initialize it like this:
OthersUsersTableViewController *tvc = [self.storyboard instantiateViewControllerWithIdentifier:#"staticTableView"];
You can set your identifier in the menu on the right where you also set the custom class for the view controller. The field is called Storyboard ID.

when you're just calling [[UIViewController alloc] init], the UI objects you've added and configured on the storyboard,does not get called or wired to your view controller.
You should instantiate the view controller through the storyboard itself by adding an identifier to your view controller(on the storyboard) and calling instantiateViewControllerWithIdentifier method of your storyboard.
You can get a reference to your storyboard through the current view controller's storyboard property.
OthersUsersTableViewController *tvc = [self.storyboard instantiateViewControllerWithIdentifier:#"identifier"];

Related

storyboard elements are not visible when using manual push navigation

i am using manual navigation on button click from one viewcontroller to another
nextpage *np = [[nextpage alloc]init];
[self.navigationController pushviewController:np animated:YES];
I included nextpage class on the viewcontroller in storyboard. But in this case the elements added via drag and drop are not visible while if i add manual elements via code they are visible from nextpage on navigating. Please help !
and If I add navigation from a button through a storyboard, in that case both coded elements and storyboard elements are visible. !
Try this.
Pass a identifier to your view controller in storyboard.
nextpage *np = [self.storyboard instantiateViewControllerWithIdentifier:#"your identifier"];
[self.navigationController pushviewController:np animated:YES];
Content you've added in the storyboard will only appear if you load that view controller from the storyboard. By simply alloc/initing a new view controller you're losing all of the information you've added in the storyboard.
You can create a segue from a view controller to another one (i.e. not from a specific button) if you want to manually push, just use performSegueWithIdentifier, or you can add an identifier to the view controller and use instantiateViewControllerWithIdentifier to create your VC from the storyboard.
first of all give storyboard id to viewcontroller then add following code
Nextpage *nextPage = [self.storyboard instantiateViewControllerWithIdentifier:#"NextpageIdentifier"];
[self.navigationController pushviewController:nextPage animated:YES];

Popover segue not working

I am developing one iPad application using storyboard. In my application i have 2 view controllers(First view controller and Modal view controller). In my first view controller I have one table view with cell containing one button. If I click the button in each cell I need to go to modal view controller. I connected the modal view controller and button by using a segue. Segue is working perfectly when style is modal but I need style Popover. When I am trying to change the segue style popover the storyboard error occurs and compilation failed comes. How can I solve this issue.
Follow the steps in the image. hope I will help you.
If the error is "Couldn't compile connection..." the problem is how XCode handles an outlet inside a dynamic table cell view.
I suggest you 2 alternatives:
1) The error doesn't come if you can use a "static" table view, in this way the table view must live inside a UITableViewController.
2) If you need a dynamic table, subclass the cell view and in your class (say MyUITableCellView) put an outlet:
#property (weak, nonatomic) IBOutlet UIButton *segueButton;
Then in your storyboard create an outlet from the prototype cell (of class MyUITableCellView) to the button inside the cell (do not create the segue in the storyboard, create only the destination view controller).
Then in the "cellForRowAtIndexPath" do the following:
MyUITableCellView *cell = (MyUITableCellView*)[tableView dequeueReusableCellWithIdentifier:#"MyCell"];
/* IMP: Here you should check if button has already this action (reused) */
[cell.segueButton addTarget:self action:#selector(showPopover:) forControlEvents:UIControlEventTouchUpInside];
and then add the action:
- (void)showPopover:(UIButton*)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *secondVC = [storyboard instantiateViewControllerWithIdentifier:#"secondVC"]; // this is the storyboard id
self.popover = [[UIPopoverController alloc] initWithContentViewController:secondVC];
CGRect fromRect = [self.view convertRect:sender.frame fromView:sender.superview];
[self.popover presentPopoverFromRect:fromRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Hope this has helped.
Have you included the <UIPopoverControllerDelegate> and implemented it? That's easy to forget the first times.
May be you might have not connected the Anchor, put UIView in your Viewcontroller view somewhere with background colour clear and set Anchor point of the Segue to that view.....

Segue to UIViewController from a xib

I have a custom UIView which is a xib file and then a class that controls this view. I also have a storyboard which a lot of different view controllers inside. How do I perform a segue from the UIView to a specific UIViewController that is inside the storyboard?
Thanks
You can't do that. What you can do is give the UIViewController a storyboard ID, using the menu on the right of the interface builder.
Then call it programatically, like so:
MyCustomViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"MyViewController"];
[self.navigationController pushViewController:vc animated:YES];
You could put a ViewController into the Storyboard, set the class to your custom ViewController. Then, if you have class files for the view in the xib, set your custom view as the VC's view (already saves some code in loadView) and then just add a segue from the custom VC to the other view controller. To trigger that segue, you have to call [self performSegueWithIdentifier:#"identifierOfSegue"] in your custom ViewController.

UICollectionview controller to UItableview controller

hi I have a uicollectionview controller with two buttons ,when i click the first button it directly opens uitableview controller(with 2 button) and when i click the second button i want uicollectionview controller to show? how can i do this in storyboard?
i tried this code inside one button but its throwing one exception like "Nib file not found"
table *listview=[[table alloc]initWithNibName:#"listview" bundle:nil];
[self.navigationController pushViewController:listview animated:NO];
{list view is the uitableviewcontroller name ,i assigned this name on uitableviewcontroller title property in right panel of xcode}
"Nib file not found" error makes me reckon that you haven't spelled the .xib's name correctly.
Lets say you have your controller you want to push to.
TableViewController.h
TableViewController.m
And a corresponding xib thats linked with TableViewController.h. (view, IBOutlets, etc).
TableView.xib
Now in your main ViewController we push to TableViewController
TableViewController *controller = [[TableViewController alloc] initWithNibName:#"TableView" bundle:nil];
[self.navigationController pushViewController:controller animated:NO];
Hope this helps.
BooRanger
We can use Story board identifier for moving from uicollectionviewcontroller to uitableviewcontroller
table *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"list"];
[self presentViewController:vc animated:NO completion:nil];
Its working fine

PushViewController doesn't do anything

This is the first time I'm trying to implement navigation from a tableView cell to another tableView using UINavigationController and it doesn't work for me.
I'm NOT using nib file and I have a simple tableView that I present it in a modal dialog in my app, it works fine, now I added the disclosureInidcator to one of it's cell, to make the user enable to choose from a fixed number of options available from another list(tableView). For this purpose I have another class that makes the second tableView. the problem is now navigation from the cell(contains disclosure icon)in first tableview to second tableView doesn't do anything, no error, no nothing. I guess the way I setup the navigation controller would be wrong, the code doesn't fall in delegate, or datasource of the second class at all.
in First TableView in method : didSelectRowAtIndexPath I tried to catch that row, then call the second tableView like this:
mySecondViewController *secondVC = [[[mySecondViewController alloc] initWithStyle:UITableViewStyleGrouped ] autorelease];
UINavigationController *navCont = [[UINavigationController alloc] initWithRootViewController: self];//not sure the first controller should act as the root controller?
[navCont pushViewController:secondVC animated:YES]; //it does nothing, no error,...
the second tableViewcontroller class contains all delegate and datasource methods, and initialization method:
- (id)initWithStyle:(UITableViewStyle)style
{
if ((self = [super initWithStyle:style])) {
}
return self;
}
and declared in interface as:
#interface stockOptionViewController : UITableViewController {
}
I tried to play with viewDidLoad, but didn't help.
Please help me cause I have no clue and all sample codes found is based on using nib files.
Thank,
Kam
Your navigation controller should be the root view controller of the app delegate's window, and the first view controller should be the root view controller of the navigation controller, then you can push new controllers onto it.
Please see the documentation for UINavigationController.
At the moment, you are creating a navigation controller but not putting it anywhere, so asking it to push new view controllers is a little pointless. You have the right code, just not in the right order.
You can present view control modally without nav controller
mySecondViewController *secondVC = [[[mySecondViewController alloc] initWithStyle:UITableViewStyleGrouped ] autorelease];
[self presentModalViewController:secondVC animated:YES];
UINavigationController should be the root view controller. In the current code, navCont is not on the view stack, so it won't work. Instead of pushing myFirstViewController in your appDelegate, push the UINavigationController to the stack and add myFirstViewController as its root view controller.

Resources