UIButton and Page linking

Discussion in 'iOS Programming' started by hoosierfan24, Aug 7, 2009.

  1. hoosierfan24 macrumors member

    Joined:
    Jul 31, 2009
    #1
    Hello I have been trying to link this single round rect button on my title page to the categories page on my application I am finished with the app except for this one thing I really need help i have been stuck on this same thing for 4 days.

    The home page of the app .xib file is HomeView.xib and the display is under the window part catagory and I want to link it to the MainView.xib and the display for this .xib is under a navigation controller.

    I have already created the IBAction *switchViews method under the HomeView.h file and attached it to the button in interface builder

    and I do not know what to put in the HomeView.m file so that when i click the button on the Homeview.xib file it will bring me to the MainView.xib

    I have read to entire books and none of them specify how to do this nor do any sample codes show either, so If you dont know how to explain this to me can u please give me a link to download a sample code that shows you how to do this

    If anyone could help me I would be more than happy because then I would be able to send my app to apple :apple:

    Thanks alot
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Is this a navbar app? No tab bar? If so then you usually pushViewController and popViewController to move up and down the navigation hierarchy. I think that's what you're describing.
     
  3. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #3
    only the o catagory page uses a navbar and that page works just fine

    what i am trying to do is to link the round rect button to the navbar page if you know how to do that that would be great
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You're still not being very clear what kinds of views you're using, what kind of hierarchy you want (if any), and how the views are related. Also, I haven't seen any mention of viewControllers which is important for, of course, controlling your views. Perhaps you might want to include some screenshots in your next post to try to clear things up.
     
  5. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #5
    sorry about making things unclear here are some screen shots

    the one picture with just the button and the window circled is going to be my home page and i am trying to link that to the 2nd picture with the navigation menu

    i hope this clears it up a little

    and I want to go from the HomeView.xib to the MainWindow.xib and the HomeView is being viewed in the Window option. Would it make more sense if ti was being displayed in the View Controller option?
     

    Attached Files:

  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Alright, starting to become clearer. Now, what do you have in terms of viewControllers? Do you have a HomeViewController class? And do you have a class for your navigationController that is a subclass of UINavigationController?

    I think you may be able to accomplish the transition to the Categories view using UIViewController's presentModalViewController:animated: but I think I need to understand your setup better.
     
  7. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #7
    Yes i Have a HomeViewController class and I think i have the class for the navigation controllers but i am not sure the class just makes it so that when you touch one of the catagories then it brings you to that screen but i dont mention a UINavigation controller any where in the Catagories supporting class.
    Do you need anything else for you to understand this better
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Maybe a list of all your controller classes and their superclasses?

    For example, HomeViewController : UIViewController (taken from the @interface specification in HomeViewController.h)
     
  9. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #9
    One suggestion, change the View Mode in IB to list view. It makes things clearer of what's in the nib.

    Second, 'Categories.' Spelling counts sometimes :rolleyes:

    I think that you have added your start view as a subview to the Window. That's not a good idea.

    Do you have an idea of how you want the Start view to go away or are you flexible about that?

    Here's one way to do this.

    Add the navbar view and rootview, Categories view, to the window in your app delegate.
    Also push the Start view as a modal view using presentModalViewController.
    When the app first appears you'll see the Start view.
    When the start button is pressed the modal view is dismissed with dismissModalViewControllerAnimated and the Start view will slide off the screen revealing the Navbar and Category view.

    You need a view controller for the Start view, but it will do very little except respond to the button tap.
     
  10. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #10
    Dejo Here are the list of the classes that

    @interface AppDelegate : NSObject <UIApplicationDelegate>

    @interface MainViewController : UITableViewController

    @interface HomeView : UIViewController {


    and the rest of them I dont think you will need
     
  11. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #11
    PhoneyDeveloper....

    My start view is not a subview to the window it is on the window itself

    and I dont care at all how the start view goes away i am just worried about getting it to go away

    and i am confused on what you are telling me to do here i dont understand it really and how to do it.

    I am also confused what the presentModalViewController does and I dont know where to put it i would appreciate it if you could write a sample code using it then I would most likely understand it better
     
  12. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009
    #12
    phoneyDeveloper...

    I think I get what you are saying now am i supposed to create a new .xib file with the Start View as the view controller, and then create a root view for it making it the Catagories view, with the nav bar right?
    and if that is correct are they all supposed to be in the same .xib file?
     
  13. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #13
    I recommend that you build a navbar app from template. It creates a framework of an app that shows a navbar and a table as the rootview controller that goes below the navbar. Your app will be very similar.

    You'll see code like this:

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application 
    {
    	// Configure and show the window
    	[window addSubview:[navigationController view]];
    	[navigationController pushViewController:rootviewController animated:NO];
    	[window makeKeyAndVisible];
    
    You want to add this:

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application 
    {
    	// Configure and show the window
    	[window addSubview:[navigationController view]];
    	[navigationController pushViewController:rootviewController animated:NO];
    	[rootviewController presentModalViewController:startViewController animated:NO];
    	[window makeKeyAndVisible];
    
    Caveat, I haven't tried this.

    You need to create a startViewController that has as its view the Start view. The start view goes in its own xib and its file's owner is StartViewController, or whatever you want to name it. You add an IBOutlet to the app delegate called startViewController. You need to connect that in IB like the rootViewController is connected to the app delegate in the navbar app you built from the template. The startViewController will be created when the app launches and loads the MainWindow.xib file.

    Add your IBAction to the startViewController and have the action method dismissModalViewControllerAnimated.
     
  14. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #14
    hoosierfan24, I believe PhoneyDeveloper is steering you in the right direction, but I must admit I'm a little concerned with statements like the above. They seem to indicate that you don't understand the relationship between a viewController, a view, and a .xib. I'm gonna suggest that you step back from the real coding and go (re)learn the basics of iPhone views and controllers and such and make sure you have a good handle on those before you come back to this project. It may take more time but I believe it will serve you better in the long run.
     
  15. hoosierfan24 thread starter macrumors member

    Joined:
    Jul 31, 2009

Share This Page