Skip to content

Commit 5145627

Browse files
committed
Updated docs for IOS usage with all params
1 parent 2d4383e commit 5145627

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

README.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Or add, the `NativeView` class directly to your android project:
102102
Shows a native view.
103103

104104

105-
**ANDROID**
105+
### ANDROID
106106

107107
```js
108108

@@ -127,15 +127,19 @@ document.addEventListener("deviceready", function() {
127127
}, false);
128128

129129
```
130-
**IOS**
130+
### IOS
131131

132-
```js
133132

134-
/*
135-
* Optionally, pass a storyboard name that contains
136-
* an UIViewController
137-
*/
133+
- Pass `Storyboard` name and `storyboard id`
134+
135+
```js
138136
document.addEventListener("deviceready", function() {
137+
138+
/*
139+
* The first param is a storyboard name, and
140+
* the second param is a storyboardId
141+
* (conventionally the same name of the ViewController class name)
142+
*/
139143
cordova.plugins.NativeView.show('MyStoryboard', 'MyUIViewController')
140144
.then(function() {
141145

@@ -146,26 +150,41 @@ document.addEventListener("deviceready", function() {
146150
*/
147151
});
148152

149-
/*
150-
* Or, pass only the UIViewController name, if you don't
151-
* use storyboards in your project.
152-
*/
153-
cordova.plugins.NativeView.show('MyUIViewController');
154-
155-
/*
156-
* Or just call the "show()" method without params.
157-
* This plugin will check whether exists a *"NavigationController"
158-
* in your project, and execute
159-
* "[popViewControllerAnimated: Yes]" method. Else, will be throw a
160-
* exception
161-
*
162-
*/
163-
cordova.plugins.NativeView.show();
164-
165153
}, false);
154+
166155
```
167156

168-
**IONIC**
157+
- Pass only the `ViewController` class/xib name
158+
159+
```js
160+
/*
161+
* Or, pass only the UIViewController name, if you don't
162+
* use storyboards in your project. This plugin try instantiate
163+
* from a ".xib" file. If not exists, try instantiate just by
164+
* UIViewController class.
165+
*
166+
* By convention, your ViewController class needs finish with
167+
* 'ViewController'.
168+
*/
169+
cordova.plugins.NativeView.show('MyUIViewController');
170+
```
171+
172+
- Pass only the `Storyboard` name
173+
174+
```js
175+
/*
176+
* Or, pass only the Storyboard name. If you don't pass a
177+
* ViewController class name in second param, the
178+
* "rootViewController" of your storyboard will be
179+
* instantiated.
180+
*
181+
* By convention, your
182+
* Storyboard name needs finish with 'Storyboard'
183+
*/
184+
cordova.plugins.NativeView.show('MyStorboard');
185+
````
186+
187+
### IONIC
169188

170189
Replace `document.addEventListener` event to `this.platform.ready().then(...)` service method. See [IONIC Platform documentation](https://ionicframework.com/docs/api/platform/Platform/)
171190
## License
@@ -174,4 +193,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
174193

175194
## TODO
176195

177-
- Better catch IOS exception from JS
196+
- [x] Better catch IOS exception from JS

src/ios/CDVNativeView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ - (void)show:(CDVInvokedUrlCommand*)command {
7272
// first param is Storyboard
7373
storyboardName = [command argumentAtIndex: 0];
7474

75-
// second param is ViewController and/or segueID
75+
// second param is ViewController and/or storyboardId
7676
viewControllerName = [command argumentAtIndex: 1];
7777

7878
// Init viewController from Storyboard with initial view Controlleror or user defined viewControllerName

0 commit comments

Comments
 (0)