[英]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.