Basically i have a WebView
on SecondViewController
and I wish for the WebView
to be visible on every view like a tab bar and fully controllable on each view.
Please note the WebView
will be on a webpage with a online slideshow so I cannot simply reload on each view
Also in the SecondViewController
I have
- (void)webViewDidFinishLoad:(UIWebView *)YouTubePlayer {
You can have all your views take up a portion of the screen and have your
UIWebView
take up the rest. The logic for switching between the other views should remain the same.For example, in your
viewDidLoad
method for yourUIViewController
s, you could have something like:And in your (say)
AppDelegate
, you would have your normal call to show the mainUIViewController
(in your case, it sounds like aUITabBarController
?) and also have a call to add theUIWebView
. Say, something like:The view controllers and
UIWebView
would be independent of each other.You see this pattern, I believe, with apps that have iAds. I've done something just like this with one of my free apps.
Hope this helps!
Could you not use two webviews on your application and simply change the uppermost webview with your more dynamic content?
I would suggest adding the
webView
on you window after the you add thetabbarcontroller.view
just like:and initially make don't make it visible. You should handle all the webview related methods in the app delegate. Now whenever you don't need it you can hide it by calling the methods your wrote in app delegate from your view controllers.
Hope this helps.
I got the same effect by simply adding it to the navigationController itself(if you don't have one then just add it). works great for me in one of my apps.
Sounds like you try to put views on top of this view but not modal. There was this blog entry I once saw that described how you would do something like this. I think it should apply also for your case: semi-modal-transparent-dialogs-on-the-iphone
The simplest approach is to just make all of your view controllers aware of this extra view (make the view available through a singleton PinnedViewController or whatever). During each view controller's
-viewWillAppear
, just do this:This will move the view to whoever is currently active (making a view your subview automatically removes you from your old hierarchy).
If that is cumbersome or otherwise unworkable, there are two other options. First, you can subclass
UITabViewController
(I assume that's what you're using here from your question), and inject your extra view (resizing the content view to make room). This is undocumented and unsupported, so take heed. But it's not incredibly difficult if you don't do too many other fancy tricks.The other tricky solution is to create a second
UIWindow
that you float over the mainUIWindow
(or resize the mainUIWindow
to make room for it). This is only semi-documented and is also not really supported. But this approach can work if you're trying to put the extra view below the tabbar for instance.But if your system is simple enough, I recommend just letting your view controllers all manage the pinned view manually. You'll save a lot of code spelunking that way, and you won't have to rely on any undocumented internal view hierarchies.