I have a UIWebView controller that loads a web page and I would like to add some kind of a bar at the top of the page with refresh and close buttons.
The bar should hide when the page loaded and should show again if the user taps the top part of the page.
Does anyone know how to approach it? Is there any simple way to do that?
UPDATE:
I think I wasn't clear enough with the question, so here are some clarifications:
1. The applications is a standard application that one of the flows opens UIWebView that loads a web page
2. What I'm looking for is a bar that will slide down on top of the web page (loaded in UIWebView) and should help the user overcome a scenario where the web page is not loaded for some reason
3. The bar should hold the back (just close the UIWebView) and refresh (reload UIWebView) operations.
Hope it helped.
Thanks,
Shimix
I'm working on something like this right now and so far, here's what I've come up with. Some of this may be obvious, but important:
Your address bar should be the left navigationItem.
The search bar is the rign navigationItem.
You should animate a cancel button in/out when beginning/ending editing in the URL box.
Safari Mobile uses the Prompt property of the navigationBar to display webpage titles.
To animate the widths of the search/URL bars, use UIView animation when the bar is selected.
It's pretty simple to add a UIToolbar above the webview with UIBarButtonItems that call the webview's refresh, back, and forward methods. You can also add the webviewdelegate methods to your view controller to detect when the page has finished loading and hide/show the toolbar that way.
If you want the refresh and navigation controls to be displayed as part of the html content of the webview itself, that's a littler tricker, but not impossible. You can use the webview's shouldLoadRequest delegate method to detect that those buttons have been tapped, and then take the appropriate action within your viewcontroller. Hiding and showing the nav bar would have to be handled in javascript.
Unless I'm missing a library/project doing this, I don't think there is a simple way to do this.
I have already coded something similar to Safari mobile address bar, and from memory, it involved using private apis and/or playing with the "not so private but use at your own risks" UIWebView subviews hierarchy...
Related
Thanks for reading my question!
I have a 5-part tabbar which I use for app navigation, the center tab is covered by a UIButton and is slightly larger (much like the instagram app). This works fine.
But what I want is the far right tab bar item to show a overlaying menu when clicked. I don't want it to switch to a viewcontroller with a menu. I want the menu to be displayed no matter which of the other views you're in at the moment. So I want it to act much like a button which is in the tabbar. But I have no idea how to go about doing this.
Should I use a overlaying button over the tabbaritem or should I catch the tabbarclick, but how can I prevent the view from changing in that case?
Thanks you for any help!
You need to implement UITabBarDelegate. Then override tabBar:didSelectItem: and implement your custom displaying here. See below for reference
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarDelegate_Protocol/Reference/Reference.html
Then i would just make a custom UIView and fade it in when that specific tagged UITabBarItem is pressed.
I'm completely new to iphone apps. I'm creating an iphone app that is designed in HTML and jquery with phonegap. I want to include a back button on the top like the default one in the iphone. I searched on net but all i found, required view controllers.I don't have multiple views so how can i include a back button on my app. Step by step explanation would be very helpful.
Thanks in advance..:)
Why would you include a "back" button if you don't have multiple views? What exactly will you navigate "back" to?
"The net" is correct, you need a UINavigationController to house a "back" button which would pop a view to the previous view.
Other than a UINavigationController, you could use a UIToolbar and set a button to the left hand corner and give it the title of "Back" to simulate the native appearance — but this would be misleading and pointless.
I don't use PhoneGap, but I am sure there is a way to simulate a NavigationController and manually place a button there. I'm also sure it won't be shaped like a back button either (with the pointy end).
javascript:history.go(-1)
UINavigationController is a native control which is in iOS frameworks. As you are using HTML, jQueryMobile and phonegap you should not be looking at those controls. You should totally work in your HTML pages and CSS for that purpose.
The below page contains that back button in jquery mobile. You should be implementing this in your html page.
http://jquerymobile.com/test/docs/toolbars/docs-headers.html
I have a UITableView which is long and scrollable, also I use UINAvigationController. At the bottom of the page in the footer I plan to put a next button which will help to go next page.
The problem is "sometimes" this page may need to show some messages in html, so I must use uiwebview preferebaly at the bottom of the page just above the footer, it shouldnt get effected from scrolling.
-Can I use uitableview and uiwebview on same page? the page is already in control of a uitableview controller, so how will i control or put delegates of a uiwebview?
-Can I make this uiwebview invisible and not allocate space when there are no messages to be shown?
Yes, it's possible.
I believe the Stocks app for the iPhone utilizes multiple views with their own controllers. I think a better solution would be is to have a UIPageControl and create a UITableViewController when the UIPageControl's value changed.
If you still want to create UINavigationController, just set its rootViewController to a UITableViewController and set its toolbarHidden property to NO, the toolbar has the behavior you want, it stays fixed on the bottom of the screen, if that's what you meant. Then add the navigational buttons.
As for UIWebView's, just dynamically create it once you get an error and set its hidden property to YES. You wouldn't want to be destroying and recreating UIWebViews every time you get an error as that can be very expensive. Just create once and hide it.
I've built the tab bar application in IB, with three tabs. The third tab happily displays a UIWebview where you can browse. The only thing missing is a back button, as not all web pages supply such a link.
I need a navigation bar hooked up properly to the correct classes. I'm still a bit unsure about exactly how the hierarchy should look in interface builder and how to hook it up properly.
Currently, the third tab is hooked up to a referencing outlet called 'webnews' in the class 'thirdviewcontroller', and the UIWebView (under a normal IUView in the hierarchy, which in turn is under the third tab bar controller) is connected to the webnews outlet.
How do I make the navbar control the webview, and do I add code to the thirdviewcontroller.m that lets the navbar on the view control the webview 'back' function? What do I hook up as the delegate for it? Currently I have an app delegate, but that's hooked up to the tab bar.
I'm not really after specific code as much as a general 'how it works' clue :) (Unless I can just add the navbar dynamically to the functioning app... but I don't think addSubView on viewWillAppear {} in thirdviewcontroller.m will create the proper functionality?)
If I were to guess at the simplest solution, I'd guess create a navbarcontroller.h/.m, slap a navbar on the view in IB, connect the third tab to navbarcontroller, connect the navbar to the webview (?) and move the webnews outlet to navbarcontroller.h, and connect the webview to it. But I don't quite have the nerve to try, better to ask advice first.
Answering this, see similar Detect and handle, or override, clicks on a navigation bar
I posted earlier but am running into similar problems again. Basically the way that my app is setup there is a top bar that is basically just a static image that has UIButtons placed on top of it. That is the Main View Controller and is persistent no matter what view is shown beneath it. I can't use a navigation controller because it is not possible to change the height and I need the bar to be significantly larger than a navbar. However my bar is functioning in much the same way. There is a "Home" Button, a "Back" Button and several destination buttons.
I understand how to switch views from say the home screen. My confusion comes with the back button. In order to press back the app is going to need to know what view is currently being displayed so that it can be removed from view and a new subview can be added. Ideally I would use the UINavigationController so that I can push and pop views which is really what I want to do here, however that is not possible because of the visual problem.
Does anybody know of a method that returns the current displayed view so I could do something like the following
[currentview.view removeFromSuperView];
[self.view insertSubview:experienceViewController.view atIndex:0]
You can use UINavigationController with the nav bar hidden. Put the nav controller inside a view that does have your jumbo toolbar and you'll have access to the push/pop behavior you're looking for.