Follow

Monitoring control events

The KGPagedDocControl class supports a number of control events that you can monitor.

  • KGControlEventDataSourceWillLoadForeground/KGControlEventDataSourceWillLoadBackground
    These events are fired prior to the page content being retrieved from the data source url. The sender object is the URL of the page that is about to be loaded.

    The Foreground event is fired when loading the foreground page that is about to be viewed. The Background event is fired when loading pages in the background in order to generate snapshots.
  • KGControlEventDataSourceDidLoadForeground/KGControlEventDataSourceDidLoadBackground
    These events are fired after the page content has been retrieved from the data source url. The sender object is an NSMutableStringcontaining the loaded content. This string can be modified if you wish to change the content before it is displayed.

    The Foreground event is fired when loading the foreground page that is about to be viewed. The Background event is fired when loading pages in the background in order to generate snapshots.
  • KGControlEventContentLoadFinished
    This event is fired after the web view has finished loading the content, but prior to the pane manager layout calculations and snapshot generation. The sender object is the UIWebView of the page.
  • KGControlEventContentSnapshotFinished
    This event is fired after all snapshots have been taken for a foreground page (if not snapshots were needed, this event will still be fired). The sender object is the UIWebView of the page.

    At this point in time it's safe to startup any javascript or make changes to the page that you wouldn't want to appear in the snapshots. If the callbackWhenSnapshotFinished metatag has been set, this is the same time that that callback would be initiated.
  • KGControlEventContentLayoutChanged
    This event is fired after the layout of the foreground page has potentially changed - typically as a result of an orientation change, or a font resize. The sender object is the control itself.
  • KGControlEventContentSizeChanged
    This event is fired when the effective size of the content in the page control has changed, that is the number of panes has changed. This typically occurs after an orientation change, a font resize or, when using variable pane partitioning, when the width of each page is first calculated. The sender object is the control itself.

To monitor one of these events you would need to call addTarget:action:forControlEvents: on the KGPagedDocControl object. For example, to monitor the KGControlEventContentLoadFinished event, you could add code like this in your DocumentViewController:

- (void)viewDidLoad {
  ...
  [pageControl addTarget:self action:@selector(contentLoadFinished:) forControlEvents:KGControlEventContentLoadFinished]; 
  ...
}  
 
- (void)contentLoadFinished:(id)sender {
  UIWebView *webView = (UIWebView*)sender;
  ...
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk