iOS Integrated Dcloud

Source: Internet
Author: User

1. Reference links

http://ask.dcloud.net.cn/docs/#http://ask.dcloud.net.cn/article/83
http://ask.dcloud.net.cn/docs/#http://ask.dcloud.net.cn/article/84

2. Note The official introduction of this sentence.

Note that developers are advised not to remove the project from the SDK directory when using the sample project, if the project is to be moved by modifying the library search path, the framework search path and the head search path to resolve the error.
Because the SDK is too large, so it is not recommended to pull in, so put in the directory, as needed to add the library, git upload ignore the folder, open. Gitignore add/sdk.
Serach under Configuration
Framework Search paths
$ (Project_dir)/sdk/libs/release-iphoneos
$ (Project_dir)/cloudstore/share/bundles
$ (Project_dir)/sdk/libs/release-iphonesimulator
Header Search paths
$ (srcroot)/sdk/inc recursive
Library search paths
$ (Project_dir)/sdk/libs/release-iphoneos
$ (Project_dir)/cloudstore/share/bundles

The middle one can pull Inc that file. I pulled it in and compiled it. You can also pull in without compiling.

3. The most important configuration

Configure other linker flags according to this file Feature-ios

It is also important to note the following several, which may not be the same.
UI and a push SDK and Nativeui note

4. Back button
OC Code- (void) button3click{//start H5 projectNSString *pwwwpath = [[[NSBundle Mainbundle] Bundlepath] stringByAppendingPathComponent:@"pandora/apps/h586661f4/www"]; Papphandle=Nil; //Create a view instead of the official code inside the Self.viewView =[[UIView alloc] initWithFrame:self.view.bounds]; View.backgroundcolor=[Uicolor Whitecolor]; View.tag= A;    [Self.view Addsubview:view];    [[Pdrcore Instance] setcontainerview:view]; Papphandle= [[[Pdrcore Instance] AppManager] Openappatlocation:pwwwpath Withindexpath:@"/html/goods/search.html"Withargs:nil Withdelegate:nil];    [[[Pdrcore Instance] AppManager] restart:papphandle]; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (textclose:) Name:@"Closewebapp" Object: nil];}- (void) Textclose: (Nsnotification *) not{//do not shut down the app in a message-triggered method requires an asynchronous way to close the app[Self performselectoronmainthread: @selector (Classwebapp) Withobject:nil waituntildone:no];}- (void) classwebapp{//call the AppManager method to close the app[[Pdrcore Instance].appmanager End:papphandle]; //you need to remove the page where H5 is located from the main view so I just put the parent view of the page where H5 is located to nil     for(UIView *subviewsinch[Self.view Subviews]) {        if(subviews.tag== A) {[Subviews Removefromsuperview]; }    }}
JS Code
Varnoticlass = Plus.ios.importClass ("Nsnotificationcenter"); Noticlass.defaultcenter (). Postnotificationnameobject ("Closewebapp",null);

Here is my part of the code, mainly based on the above reference and the official reference, using the widget mode. WebView and App mode try as if it's not quite ok.

[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (textclose:) Name:@"Closewebapp" Object: nil]; //0 for widget 1 for WebView 2 for app mode,    intJHB =0; Switch(JHB) { Case 0:        {            //The agent basically modifies the styleH5engine.coredeleagete =Self ; //set the parent view of the runtime root[H5engine Setcontainerview:_containerview]; //Set 5+runtime ViewcontollerH5engine.persentviewcontroller =Self ;            [H5engine Showloadingpage]; Dispatch_async (Dispatch_get_main_queue (),^(void) {[H5engine start];        }); }             Break;  Case 1:        {            if(H5engine! =Nil)                {[H5engine startaswebclient]; NSString* Pfilepath =@"http://www.baidu.com"; NSString* Pfilepath =@"http://192.168.60.109/cloudstore/html/index.html"; CGRect Strect= CGRectMake (0, -, Self.view.frame.size.width, Self.view.frame.size.height- -); Pdrcoreappframe* Appframe = [[Pdrcoreappframe alloc] Initwithname:@"WebViewID1"Loadurl:pfilepath Frame:strect];                [H5Engine.appManager.activeApp.appWindow Registerframe:appframe];                [_containerview Addsubview:appframe];            [Self.view Addsubview:_containerview]; }        }             Break;  Case 2:{            //webapp mode local applicationpdrcoreapp* Papphandle =Nil; //set the directory where the WebApp is located, which must have Mainfest.jsonNSString *pwwwpath = [[[NSBundle Mainbundle] Bundlepath] stringByAppendingPathComponent:@"pandora/apps/com.baobeigou.b2b/www"]; //If the path contains Chinese, or the Xcode project's targets name is Chinese, the path needs to be encodednsstring* pWWWPath2 = (NSString *) Cfbridgingrelease (Cfurlcreatestringbyaddingpercentescapes (Kcfallocatordefault, (CFSTRINGREF) PWWWPath, NULL,            NULL, kCFStringEncodingUTF8)); //Create a view instead of the official code inside the Self.viewuiview* view =[[UIView alloc] initWithFrame:self.view.bounds]; View.backgroundcolor=[Uicolor Whitecolor]; View.tag= at;            [Self.view Addsubview:view]; //set the view 5+sdk run[[Pdrcore Instance] setcontainerview:view]; //incoming parameters can be obtained through the plus.runtime.arguments parameter in the page. Not a pass.//nsstring* Pargus = @ "Id=plus.runtime.arguments"; //Create an appPapphandle = [[[Pdrcore Instance] AppManager] Openappatlocation:pwwwpath Withindexpath:@"index.html"Withargs:nil Withdelegate:nil]; //It is recommended to use the Restart method if the app may be opened repeatedly[[[ Pdrcore Instance] AppManager] restart:papphandle]; }             Break; default: {NSLog (@"input h5 run mode"); }             Break; }

can refer to

Back button HTTP://WWW.JIANSHU.COM/P/FFF3F2FF99C9

Other http://www.jianshu.com/p/d9050a1b765e

The above may be a bit messy.

The following runtime only refers to the runtime in the H5 environment.
The H5 environment runtime shuts down when the jailbreak machine may crash, a little pit did not find the cause.
In order to user experience, click H5 This module does not need to wait a few seconds, the app started running runtime, remember the single example under this controller, memory is increased (but as if the exit interface closed runtime, memory increases later also did not significantly reduce), at the outset also worried about the audit, After all, there are too many configuration items, we need to go to the official website to search the audit, manifest this configuration should not be pits. Without notice, appdele those notices need to be hidden away, or the audit will not be too. There is also due to H5 side account synchronization reason, so when the account log out, I shut down the runtime, log in successful time to restart runtime. Resolved when the account is not synchronized, the judge does not load, and then stuck in the H5 environment can only exit the app.

About optimizations (not implemented): When the background mode is turned off when the runtime switches the foreground on. The iOS system itself optimizes memory as if it were valid.

requirements (not implemented), according to the parameters to determine the different pages, so remember the controller needs a single case. There is also a return page to determine the controller type. return type pop or dismiss, this part is only related to one of the ad pages in the project is a modal to H5 module.

iOS Integrated Dcloud

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.