[英]How to add a TabbarController using phone gap for iPhone App
[英]How to make a iPhone app using both phone gap and native app
我已经开发了过去2年的iPhone
原生应用程序。 但现在我正在努力学习phone gap
。 我已经看到了使用index.html
作为起始页面的手机间隙样本,但我想制作一个既有native
也有phone gap
的应用程序。所以任何人都可以指导我如何使用本机组件,如viewController
, navigationBar
, tabBarController
组件和手机的差距。 另外,如果您有任何对我有帮助的教程,我会看到很多教程,但所有教程都是旧的,不能在我的Xcode 4.5上运行。
在插件的帮助下,您可以在手机间隙中使用本机代码,例如我粘贴一些代码
#import <UIKit/UIKit.h>
#import <Cordova/CDVPlugin.h>
@interface PushToken : CDVPlugin
{
NSString* callbackID;
}
@property (nonatomic, copy) NSString* callbackID;
- (void) getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end
#import "PushToken.h"
#import "AppDelegate.h"
@implementation PushToken
@synthesize callbackID;
-(void)getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
self.callbackID = [arguments pop];
NSString *token = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).token;
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[token stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if(token.length != 0)
{
[self writeJavascript: [pluginResult toSuccessCallbackString:self.callbackID]];
}else {
[self writeJavascript: [pluginResult toErrorCallbackString:self.callbackID]];
}
}
@end
.js file
var PushToken = {
getToken: function(types, success, fail) {
return cordova.exec(success, fail, "PushToken", "getToken", types);
}
};
including .js file
<script src="PushToken.js"></script>
calling
PushToken.getToken(
["getToken"] ,
function(token) {
devToken = token;
//navigator.notification.alert(devToken);
},
function(error) {
navigator.notification.alert("Error :Token Not Found "+error);
}
);
may be helpful
thanks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.