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

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,944
40
Australia
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.
 
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.
 
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.
OK, I've got the view controller for the UIWebView, etc.
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.)
I also have this second view controller for bookmarks, so I'll go read that.
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).
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.
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.
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)
 
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.
 
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)

MythicFrost said:
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.

That view that slides up is probably, more than likely, a view presented modally.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.