Building a web browser -- problem with bookmarks / history (Navigation Controller)

Discussion in 'iOS Programming' started by MythicFrost, Sep 27, 2010.

  1. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #1
    Hi,

    So, I'm working on building my own web browser and I've come to try and replicate the bookmarks / history page (view) in Safari on the iPhone, however, that's a lot harder than I thought.

    I have my main project which is a view based project and when you tap my "show bookmarks" button, up pops my other UIView I made just to have the bookmarks on -- however, I (think I) need to setup a Navigation View Controller somehow instead of the UIView, however, I'm not sure how to do that. I want that sliding functionality when you tap a folder, etc.

    What do I do here? How do I setup this Navigation Controller? When I go to new file there isn't any option for subclass of Navigation Controller, only UIView, NSObject, etc.
     
  2. (marc) macrumors 6502a

    (marc)

    Joined:
    Sep 15, 2010
    Location:
    the woods
    #2
    You'll have to read up on the MVC model (Model - View - Controller). Basically, you'll need a view controller to control the main view with the UIWebView in it. Then, you'll need another view controller to control the bookmarks / history view. Once you have that controller, you can create a UINavigationController with your bookmarks / history view controller as the root view controller (look at UINavigationController's class reference for this.)

    Finally, for the sliding effect, you can present your bookmarks / history view controller from your main view controller via presentModalViewController:animated: (look in the UIViewController class reference for more info about this).

    Also, in case you didn't notice this before, at the very top of each class reference, there's a section named "Related sample code". It's very helpful to see how everything works together.
     
  3. MythicFrost thread starter macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #3
    OK, I've got the view controller for the UIWebView, etc.
    I also have this second view controller for bookmarks, so I'll go read that.
    Oh, I wasn't referring to that. I'm currently already doing that -- I mean, when the bookmark view is open and you tap a folder, I.E history, the UITableView content seems to "slide" inside of that folder -- the same as with Safari.
    Ah, ok, thanks.

    So, I've gone and read parts of those documents, however, I'm just not understanding it -- just bits of it.

    I don't know where I set this my UIView to be the root view controller of this UINavigationController (which I create programatically?) -- I thought of my didAppFinishLaunching function but it's for my main UIView, not my bookmark UIView.

    I do know of the initWithRootViewController (for UINavigationView), but where do I put that line of code?

    Also, often in the documentation you told me to read, it mentioned something about a UITableViewController which seems important, it said I need one of those for every UITableView I show.

    EDIT: Do I have this right:
    UIView (bookmarks) > UINavigationController > UIView with content

    I read UINavigationController has an option to show a toolbar -- do I have that correct?

    EDIT 2: Or is it UINavigationController > UIView with content (dump the UIView for bookmarks)
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    As stated in the View Controller Programming Guide for iOS:
    The same goes for UITabBarController.
     
  5. MythicFrost thread starter macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #5
    Ok, got that. I'm reading through it now.

    Is it possible to have a UINavigationController display a normal view with a UIWebView on it, etc.

    I see when I tap the show bookmarks button in Safari, the new UIView that slides up is underneath it -- I'm guessing because Apple has it in a UINavigationController therefore the toolbar is topmost.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7)

    That view that slides up is probably, more than likely, a view presented modally.
     

Share This Page