The iOS framework that grows only as fast as its documentation
NIWebController Class Reference

Overview

A simple web view controller implementation with a toolbar.

Subclassing

This view controller implements UIWebViewDelegate. If you want to implement methods of this delegate then you should take care to call the super implementation if necessary. The following UIViewWebDelegate methods have implementations in this class:

- webView:shouldStartLoadWithRequest:navigationType:
- webViewDidStartLoad:
- webViewDidFinishLoad:
- webView:didFailLoadWithError:

This view controller also implements UIActionSheetDelegate. If you want to implement methods of this delegate then you should take care to call the super implementation if necessary. The following UIActionSheetDelegate methods have implementations in this class:

- actionSheet:clickedButtonAtIndex:
- actionSheet:didDismissWithButtonIndex:

In addition to the above methods of the UIActionSheetDelegate, this view controller also provides the following method, which is invoked prior to presenting the internal action sheet to the user and allows subclasses to customize the action sheet or even reject to display it (and provide their own handling instead):

- shouldPresentActionSheet:

Recommended Configurations

Default

The default settings will create a toolbar with the default tint color, which is normally light blue on the iPhone and gray on the iPad.

Colored Toolbar

The following settings will change the toolbar tint color (in this case black)

[webController setToolbarTintColor:[UIColor blackColor]];

Tasks

Accessing the Toolbar
UIToolbar * toolbar property
 
BOOL toolbarHidden property
 
UIColor * toolbarTintColor property
 
Accessing the Web View
UIWebView * webView property
 
Creating a Web Controller
(id) - initWithRequest:
 
(id) - initWithURL:
 
Loading a Request
(void) - openURL:
 
(void) - openRequest:
 
(void) - openHTMLString:baseURL:
 
Subclassing the Web Controller
(BOOL) - shouldPresentActionSheet:
 

Method Documentation

toolbar

The toolbar.

@property (nonatomic, readonly, strong) UIToolbar* toolbar;

toolbarHidden

The visibility of the toolbar.

@property (nonatomic) BOOL toolbarHidden;
Discussion

If the toolbar is hidden then the web view will take up the controller's entire view.

toolbarTintColor

The tint color of the toolbar.

@property (nonatomic, weak) UIColor* toolbarTintColor;

webView

The internal web view.

@property (nonatomic, readonly, strong) UIWebView* webView;

initWithRequest:

Initializes a newly allocated web controller with a given request.

- (id)initWithRequest:(NSURLRequest *)request;
Discussion

Once the controller is presented it will begin loading the given request.

This is the designated initializer.

initWithURL:

Initializes a newly allocated web controller with a given URL to request.

- (id)initWithURL:(NSURL *)URL;
Discussion

Once the controller is presented it will begin loading the given URL.

openURL:

Loads a request with the given URL in the web view.

- (void)openURL:(NSURL *)URL;

openRequest:

Load the given request using UIWebView's loadRequest:.

- (void)openRequest:(NSURLRequest *)request;
Discussion
Parameters
requestA URL request identifying the location of the content to load.

openHTMLString:baseURL:

Load the given request using UIWebView's loadHTMLString:baseURL:.

- (void)openHTMLString:(NSString *)htmlString baseURL:(NSURL *)baseUrl;
Discussion
Parameters
htmlStringThe content for the main page.
baseUrlThe base URL for the content.

shouldPresentActionSheet:

This message is called in response to the user clicking the action toolbar button.

- (BOOL)shouldPresentActionSheet:(UIActionSheet *)actionSheet;
Discussion

You can provide your own implementation in your subclass and customize the actionSheet that is shown to the user or even cancel the presentation of the actionSheet by returning NO from your implementation.

Parameters
actionSheetThe UIActionSheet that will be presented to the user.
Returns
YES to present the actionSheet, NO if you want to perform a custom action.