Opening Another Xib form an Xib - iphone

Not a Noob as yesterday, but still green. I have been playing around with the code that Elisabeth Robson has put together HERE. I have a UITabbarcontoller and a IUNavigationController they seem to work fine. I have a UITableviewController to which I loads my NSMutable array. The user clicks a cell and didSelectRowAtIndexPath xib is loaded onto the stack. I put a 'Learn More' button on the current xib(BookDetailView). I've tried a few approaches to load a newer xib when the 'Learn More' button is pressed but have failed.
Ive Tried IBAction and Pushing the Newer xib to the top.
Do I need to create another view controller?
Thanks for looking.

I suggest linking your UIButton to an IBAction
-(IBAction) learnMoreClicked;
You will need a ViewController for your "learn more" view and in the IBAction method, you load it as follow:
[[LearMoreViewController alloc] initWithNibName:#"LearMoreView" bundle:nil];
Then you can either push it on your navigation stack or as a modal view.

Related

TabBarController called by a TableViewCell in another TabBarController

I was wondering if it is possible to have the following:
One TabBarController with two buttons containing a UITableView in each one.
Then, if one of the TableView cells is clicked, I would like to push to a new TabBarController with a different set of 4 buttons containing other table views.
Can anyone point me in the right direction?
The first thing I tried was set up the first TabBarController with the UITableView under each button. But when I added the second TabBarController to be triggered from a clicked tableview cell, what I got was the first Tab which contains the 2 buttons, and on top of that, the second tab containing the 4 buttons.
I would like the second TabBarController to replace and leave behind the first one.
I hope I explained myself well enough, thank you for your time.
You should change your push segue to a modal segue.
To go back you are going to need to implement a return button in your destination viewController:
- (IBAction) dismiss:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
(note that you must do this in code - you cannot draw a segue line to go back)
At the moment you must have a navigation controller involved in your push segue. When you change to a modal segue you can remove the navController, it won't play a part in the navigation.

Segue to a ViewController from non-Storyboard ViewController

Im using Storyboard for most screens in my iPhone app. However, I have one screen in my storyboard where I dynamically load a XIB an embedded it within the main view. This XIB have an image and some text and is connected to its own UIViewController.
My problem is that when I tap on the image in the XIB I want to segue to another UIViewController in my Storyboard. However, because my XIB is not in my Storyboard (its dynamically added at runtime) there is no way I can connect my XIB's view controller with a segue.
I'm getting the error "Receiver () has no segue with identifier". This makes sense because the segue is not connected so is there anyway tha tI can programmatically segue to the other view?
I've seen examples where I can have a modal transition, but instead I would like to have a "push" transition.
Thanks
Brian
I don't know if I really understand your question, but if you want a push transition, use this:
[self.navigationController pushViewController:someViewController animated:YES];

Getting empty view and blank navigation bar when I use popViewControllerAnimated

I'm writing an iPhone app that is based on a UINavigationController. I'm pulling data from a server that sometime returns bogus links. I open each link by pushing a webview viewcontroller. I want to be able to include some error handling. I know if the link is no good. So I want to be able to pop the webview view controller as soon as I know that my webview has encountered an error.
Currently, I've tried using the following code:
[self.navigationController popViewControllerAnimated:YES];
I then get a Navigation bar with nothing displayed in it, but if I click where the "back" button should be it operates appropriately. The title pops up when I click where the "back" button should be. The view where the viewcontrollers usually display there content is blank white too even though I'm popping back to a UITableViewController.
I've tried this as a workaround:
UINavigationController *nav = self.navigationController;
[self.navigationController popViewControllerAnimated:YES];
[nav.visibleViewController.view setNeedsDisplay];
I've checked the viewControllers array in the UINavigationController and it has the right viewcontrollers in it (ie it has removed the viewcontroller for the webview).
I also tried putting code in the viewWillAppear of the viewcontroller I'm popping back to, but the method is never getting called.
I'm looking for a way to force the UINavigationController to reload the same way that you can call reloadData on a UITableView.
Any help would be greatly appreciated.
I saw something like this on my app where I was using a navigation bar I added in Interface Builder on the root view of a navigation controller and then programmatically creating the nav bar and its subviews for the second view. When I would pop the second view to return to the first view I would hide the self.navigationcontroller bar which would show the white space underneath until the IB nav bar of the previous view appeared. To fix this I decided to stick with programmatically creating all my navbars which fixed the issue for me.
TL;DR - if you are using both IB and programmatically made navbars this can happen when popping views, stick with one or the other for all the navbars yo

IUNavigationController loading more viewControllers

Not a Noob as yesterday, but still green.
I have a UITabbarcontoller and a IUNavigationController they seem to work fine. I have a UITableviewController to which I loads my NSMutable array. The user clicks a cell and didSelectRowAtIndexPath xib is loaded onto the stack. I have a 'Learn More' button on the current xib. I've tried a few approaches to load a newer xib when the 'Learn More' button is pressed but have failed. Im thinking it has to do with the Navigation Controller? Do I need to import the navigationcontroller to every ViewControllerSubclass I make? Thanks.
Usually one calls:
[self navigationController] pushViewController:newViewController animated:YES]
to push a new controller onto the view stack. So when the Learn More is pressed, you create a new controller (-initWithNibName:bundle:) and load it using that. Be sure to release the new controller.
Look at the UIViewController documentation for more.

Problem in the flow of custom back button when using UIView controller

I am new to iphone development.I have created a button in UIView controller.On clicking the button it navigates to a another UITableView controller .On clicking the row of the table leads to another UIView controller which has also another table in it.On clicking the row of this table leads to another UIWebView.I have created a custom back button placed on the navigation bar of the UIView controllers and UIWebview.On clicking on the back button just leads me to the main page with a button and not to its just previous UIView.
-(IBAction) goemenbutton : (id) sender
{
[self.view removeFromSuperview];
}
The above method is used for all the custom back button.Please help me out to get the correct flow for the back button.Thanks.
You should probably look at using UINavigationController instead of interchanging several views within one UIViewController. The UINavigationController takes care of a lot of things for you, including back buttons with proper titles and nice animations. It also helps you structure your code and gives you more flexibility down the road.
A UIWebview is not a UIViewController and can not be pushed onto the NavigationController. You should probably look at wrapping it into a UIViewController.