tags:

views:

1881

answers:

2

Anyone have some sample code for an in-app browser that they would like to share?

I am looking to add a browser view in my app that is pushed and includes a toolbar with four buttons: back, forward, stop/refresh and actions. However, I'd like to show somewhat transparent and none-tapable buttons when you can't go forward or back, and also have the stop/refresh button show the appropriate icon when it's loading and done loading?

My issue is currently that I cannot get "blanked out" back and forward that cannot be tapped if you cannot go back in the web history. Also, how do I change out the stop icon with the refreshing icon when the view is loading?

A: 

For tool bar items, simply set "item.enabled = webview.canGoForward;" (or canGoBack). To change the refresh/stop button you can set item.customView if you want to use a progress view or some such, otherwise if you just want to use a static image you can set item.image. All this is in the documentation as well.

Ben Lachman
Thanks for the help. I have one issue. I cannot replace the stop icon with the refresh icon once the view is done loading. I have tried "stopOrRefreshItem.style =" and also tried allocating a new UIBarButtonItem and replacing my "stopOrRefreshItem = newItem" but that doesn't work. I have to use customViews for this?
Canada Dev
You want to create a new item with the (system) refresh icon and swap it in for the existing stopOrRefreshItem. You can't just set the pointer, you actually have to access the toolbar and get its items, remove the old item and insert the new item. You could also possibly create the new refresh item and set stopOrRefreshItem.image = newItem.image --I have no idea if this would actually work however.
Ben Lachman
A: 

This link here explains how to change the refresh button to an activity indicator.

Suicidal