【问题标题】:MobileFirst My migrated iOS project unresponsive if I extend WLAppDelegate, but not if I extend WLCordovaAppDelegateMobileFirst 如果我扩展 WLAppDelegate,我迁移的 iOS 项目无响应,但如果我扩展 WLCordovaAppDelegate 则没有
【发布时间】:2016-02-11 23:17:48
【问题描述】:

我已使用 MobileFirst Studio 将 9 个 iOS 混合应用程序从 MobileFirst 6.3 迁移到 MobileFirst 7.1。其中 4 个应用程序运行良好。但是另外 5 个,UI 对点击没有响应。作为自动迁移过程的一部分,这 5 个应用程序的标头(仅)已更改为引用新的 WLAppDelegate 接口。奇怪的是,我注意到如果我将 AppName.h 文件从扩展 WLAppDelegate 切换回扩展原始 WLCordovaAppDelegate,一切正常。为什么?我很乐意将此已弃用的代码移至您的新 WLAppDelegate 界面。

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

这是我的非工作 .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

【问题讨论】:

    标签: ios migration ibm-mobilefirst mobilefirst-studio


    【解决方案1】:

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

    【讨论】:

    • Idan,只有在我尝试使用 WLAppDelegate 时才会出现挂起。 UI 对点击完全没有反应。如果我切换回 WLCordovaAppDelegate,我不会遇到任何问题。有任何想法吗?这是我的 .m 代码..
    • 我继续打开 PMR 51828,442,000 来跟踪这个问题。我没有被阻止,因为我可以继续使用旧的值得信赖的 WLCordovaAppDelegate,但最好能解决,这样我最终可以向前迁移。
    猜你喜欢
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多