user355377
user355377

Reputation: 11

iPhone OS: Sharing a UIWebView between ViewControllers in a UITabBarController

I am trying to create a application with a tab bar and a common WebView.

The different tabs shows/hides different divs in the WebView but maintain the state otherwise, so I need to share the web view between the tabs.

I am trying to use a nib, but I think that might not be the right solution here.

Any pointers for doing this correctly?

Upvotes: 1

Views: 568

Answers (1)

Can Berk Güder
Can Berk Güder

Reputation: 113310

You don't need a UITabBarController, a UITabBar would suffice. You only need to assign it a delegate, and implement the tabBar:didSelectItem: delegate method.

Here's what I would do:

  1. Create a view controller and add a UITabBar and a UIWebView
  2. Set UITabBar's delegate to this view controller and implement tabBar:didSelectItem:
  3. Show/hide divs as necessary in tabBar:didSelectItem:

Upvotes: 4

Related Questions