博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【iOS Web App】嵌入 Cordova WebView 到 iOS(XCode 4.6,Cordova 2.3.0+)
阅读量:7063 次
发布时间:2019-06-28

本文共 2460 字,大约阅读时间需要 8 分钟。

参考:

 

开发环境:

XCode 4.6

Cordova 2.3.0

 

准备工作

<1 新建config.xml文件

新建config.xml文件,添加到项目中。

 

<2 创建www目录

在项目根目录下,创建文件夹www

在www文件夹下,新建文件index.html文件

范例:

                            

Hello World!

“Create folder references for any added folder”,添加到项目中

 

1、添加CordovaLib子项目

cordova-2.3.0/cordova-ios/CordovaLib下,将CordovaLib.xcodeproj拖拽到项目中

TARGET-> Build Settings -> Other Linker Flags,添加 -all_load 和 -Obj-C 

TARGET -> Build Phases -> Link Binaries with Libraries,添加一下frameworks:

  • AddressBook.framework
  • AddressBookUI.framework
  • AudioToolbox.framework
  • AVFoundation.framework
  • CoreLocation.framework
  • MediaPlayer.framework
  • QuartzCore.framework
  • SystemConfiguration.framework
  • MobileCoreServices.framework
  • CoreMedia.framework

TARGET -> Build Phases -> Target Dependencies,添加CordovaLib

TARGET -> Build Phases -> Link Binaries with Libraries,添加CordovaLia.a

TARGET-> Build Settings -> Header Search Path,添加一下项:(注意:带引号

"$(TARGET_BUILD_DIR)/usr/local/lib/include"

"$(OBJROOT)/UninstalledProducts/include"

"$(BUILT_PRODUCTS_DIR)" 

 

2、使用

新建CDVViewController子类

示例:

#import 
#import
@interface ViewController : CDVViewController@end

 

设置该对象的wwwFolderName属性,startPage属性

示例:

#import "AppDelegate.h"#import "ViewController.h"@implementation AppDelegate- (void)dealloc{    [_window release];    [_viewController release];    [super dealloc];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];    self.viewController = [[ViewController new] autorelease];    self.viewController.wwwFolderName = @"www";    self.viewController.startPage = @"index.html";    self.viewController.useSplashScreen = YES;        self.window.rootViewController = self.viewController;    [self.window makeKeyAndVisible];    return YES;}@end

 

 运行结果:

 

 

转载于:https://www.cnblogs.com/dyingbleed/archive/2013/02/01/2888747.html

你可能感兴趣的文章
JVM垃圾回收机制
查看>>
背包问题
查看>>
要吃鲷鱼到岛上钓
查看>>
图片自适应宽度显示正方形
查看>>
如何提高队列的消息处理效率
查看>>
Java中的代理
查看>>
Android深度探索读后感 第三章
查看>>
Aidl
查看>>
顺序表的静态建立
查看>>
「技巧」如何快速安装 Sketch 插件
查看>>
C#中对文件的操作小结
查看>>
事件流
查看>>
苹果中毒员工称症状复发:入住当地医院遭拒
查看>>
numpy数组及处理:效率对比
查看>>
javascript事件模型
查看>>
线性表
查看>>
spring 的权限控制:security
查看>>
python基础===map和zip的用法
查看>>
常见复杂指针声明的解析(很详细)
查看>>
Java反射(Reflection)获取运行时类的结构
查看>>