MobileFirst 如果我扩展 WLAppDelegate,我迁移的 iOS 项目无响应,但如果扩展 WLCordo



我已经使用 MobileFirst Studio 将 9 个 iOS Hybrid 应用程序从 MobileFirst 6.3 迁移到 MobileFirst 7.1。 其中4个应用程序工作正常。 但其他 5 个,UI 对点击没有响应。 作为自动迁移过程的一部分,这 5 个应用的标头(仅(已更改为引用新的 WLAppDelegate 接口。 奇怪的是,我注意到,如果我将我的AppName.h文件从扩展WLAppDelegate切换回扩展原始WLCordovaAppDelegate,一切正常。 为什么? 我很想把这个不推荐使用的代码移到你的新的 WLAppDelegate 接口上。

我的头文件和.m文件与MobileFirst Studio 7.1在您请求新的iOS应用程序时生成的默认值匹配,因此它必须是其他内容。

这是我的非工作 .h 和 .m 文件

//
//  MyAppDelegate.h
//
//
#import <IBMMobileFirstPlatformFoundationHybrid/IBMMobileFirstPlatformFoundationHybrid.h>

@interface MyAppDelegate : WLAppDelegate <WLInitWebFrameworkDelegate> {
}
@end
//
//  MyAppDelegate.m
//  IssuesReturns
//
//
#import "IssuesReturns.h"
#import <IBMMobileFirstPlatformFoundationHybrid/IBMMobileFirstPlatformFoundationHybrid.h>
#import "CDVMainViewController.h"
@implementation MyAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
    BOOL result = [super application:application didFinishLaunchingWithOptions:launchOptions];
    // A root view controller must be created in application:didFinishLaunchingWithOptions:  
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIViewController* rootViewController = [[UIViewController alloc] init];     
    [self.window setRootViewController:rootViewController];
    [self.window makeKeyAndVisible];
    [[WL sharedInstance] showSplashScreen];
    // By default splash screen will be automatically hidden once Worklight JavaScript framework is complete. 
    // To override this behaviour set autoHideSplash property in initOptions.js to false and use WL.App.hideSplashScreen() API.
    [[WL sharedInstance] initializeWebFrameworkWithDelegate:self];
    return result;
}
// This method is called after the WL web framework initialization is complete and web resources are ready to be used.
-(void)wlInitWebFrameworkDidCompleteWithResult:(WLWebFrameworkInitResult *)result
{
    if ([result statusCode] == WLWebFrameworkInitResultSuccess) {
        [self wlInitDidCompleteSuccessfully];
    } else {
        [self wlInitDidFailWithResult:result];
    }
}
-(void)wlInitDidCompleteSuccessfully
{

    UIViewController* rootViewController = self.window.rootViewController;
    // Create a Cordova View Controller
    CDVMainViewController* cordovaViewController = [[CDVMainViewController alloc] init] ;
    cordovaViewController.startPage = [[WL sharedInstance] mainHtmlFilePath];
    // Adjust the Cordova view controller view frame to match its parent view bounds
    cordovaViewController.view.frame = rootViewController.view.bounds;
    // Display the Cordova view
    [rootViewController addChildViewController:cordovaViewController];  
    [rootViewController.view addSubview:cordovaViewController.view];
    [cordovaViewController didMoveToParentViewController:rootViewController];  
}
-(void)wlInitDidFailWithResult:(WLWebFrameworkInitResult *)result
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR"
                                                  message:[result message]
                                                  delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
    [alertView show];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

> WLCordovaAppDelegate 是一个已弃用的兼容性 API,允许更轻松地将 v6.2 之前的应用程序迁移到 6.2+ 应用程序。可以使用它,但建议使用 WLAppDelegate .

相关内容

最新更新