iOS - Using native pages
In this tutorial, integration of native and web "pages" in an iOS application will be explained by using the
As a first step,
WL.NativePage.show() needs to be implemented in order to open the native page:
nativePageClassName: The name of a native iOS UIViewController instance to start.
backFromNativePage: A callback function to call when the native page closes.
params: optional custom parameters object to pass to the native code.
To handle the callback function:
backFromNativePage(data): After the native closes, it can pass data back to the web part of an application.
Creating a native page
To manage to native page, the generated iOS projects need to be opened in Xcode and afterwards:
Add a new Cocoa Touch Class file, make sure it is a subclass of
UIViewController, and save it in the
Classes folder of the Xcode project.
If working with existing .m and .h files, the files must be referenced while in Xcode.
Placing the .m and .h files only in the
iphone\native\Classes> folder in Eclipse is not sufficient, as these files will not be referenced in the Xcode project unless added in Xcode.
To retrieve custom data parameters that are passed from the web view, the
setDataFromWebView:(NSDictionary*)data method should be used:
Returning control to the web view
When the native page switches back to the web view, a
[NativePage showWebView:] method should be called.
To pass data back to the web view can be done by using the
NSDictionary object. For example:
Click to download the Studio project.