2012-10-03 96 views
2

我創建使用科爾多瓦2.1.0一個應用程序,但建設過程中,我得到以下警告實例方法「-supportsOrientation」未找到

實例方法「-supportsOrientation:」未找到(返回類型默認值到'id')。

這是我AppDelegate.m文件 -

/* 
Licensed to the Apache Software Foundation (ASF) under one 
or more contributor license agreements. See the NOTICE file 
distributed with this work for additional information 
regarding copyright ownership. The ASF licenses this file 
to you under the Apache License, Version 2.0 (the 
"License"); you may not use this file except in compliance 
with the License. You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, 
software distributed under the License is distributed on an 
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express or implied. See the License for the 
specific language governing permissions and limitations 
under the License. 
*/ 

// 
// AppDelegate.m 
// 
// Created by ___FULLUSERNAME___ on ___DATE___. 
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. 
// 

#import "AppDelegate.h" 
#import "MainViewController.h" 

#import <Cordova/CDVPlugin.h> 


@implementation AppDelegate 

@synthesize window, viewController; 

- (id) init 
{ 
    /** If you need to do any extra app-specific initialization, you can do it here 
    * -jm 
    **/ 
    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 

    self = [super init]; 
    return self; 
} 

#pragma UIApplicationDelegate implementation 

/** 
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up) 
*/ 
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions 
{  
    NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]; 
    NSString* invokeString = nil; 

    if (url && [url isKindOfClass:[NSURL class]]) { 
     invokeString = [url absoluteString]; 
     NSLog(@"Shop launchOptions = %@", url); 
    }  

    CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
    self.window = [[UIWindow alloc] initWithFrame:screenBounds]; 
    self.window.autoresizesSubviews = YES; 

    self.viewController = [[MainViewController alloc] init]; 
    self.viewController.useSplashScreen = YES; 
    self.viewController.wwwFolderName = @"www"; 
    self.viewController.startPage = @"index.html"; 
    // self.viewController.invokeString = invokeString; 

    // NOTE: To control the view's frame size, override [self.viewController viewWillAppear:] in your view controller. 

    // check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation 
    BOOL forceStartupRotation = YES; 
    UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation]; 

    if (UIDeviceOrientationUnknown == curDevOrientation) { 
     // UIDevice isn't firing orientation notifications yet… go look at the status bar 
     curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation]; 
    } 

    if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) { 
     if ([self.viewController supportsOrientation:curDevOrientation]) { 
      forceStartupRotation = NO; 
     } 
    } 

    if (forceStartupRotation) { 
     UIInterfaceOrientation newOrient; 
     if ([self.viewController supportsOrientation:UIInterfaceOrientationPortrait]) 
      newOrient = UIInterfaceOrientationPortrait; 
     else if ([self.viewController supportsOrientation:UIInterfaceOrientationLandscapeLeft]) 
      newOrient = UIInterfaceOrientationLandscapeLeft; 
     else if ([self.viewController supportsOrientation:UIInterfaceOrientationLandscapeRight]) 
      newOrient = UIInterfaceOrientationLandscapeRight; 
     else 
      newOrient = UIInterfaceOrientationPortraitUpsideDown; 

     NSLog(@"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation); 
     [[UIApplication sharedApplication] setStatusBarOrientation:newOrient]; 
    } 

    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

// this happens while we are running (in the background, or from within our own app) 
// only valid if Shop-Info.plist specifies a protocol to handle 
- (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url 
{ 
    if (!url) { 
     return NO; 
    } 

    // calls into javascript global function 'handleOpenURL' 
    NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url]; 
    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString]; 

    // all plugins will get the notification, and their handlers will be called 
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; 

    return YES;  
} 

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{  
    // IPhone doesn't support upside down by default, while the IPad does. Override to allow all orientations always, and let the root view controller decide whats allowed (the supported orientations mask gets intersected). 
    NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown); 
    return supportedInterfaceOrientations; 
} 

@end 

我不能也運行應用程序,以下是越來越顯示在日誌中的錯誤 -

2012-10-03 16:38:07.653 Shop[829:13403] Multi-tasking -> Device: YES, App: YES 
2012-10-03 16:38:07.671 Shop[829:13403] -[MainViewController supportsOrientation:]: unrecognized selector sent to instance 0x7e725e0 
2012-10-03 16:38:07.718 Shop[829:13403] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewController supportsOrientation:]: unrecognized selector sent to instance 0x7e725e0' 
*** First throw call stack: 
(0x1a2022 0x207dcd6 0x1a3cbd 0x108ed0 0x108cb2 0x2dfa 0x337386 0x338274 0x347183 0x347c38 0x33b634 0x271fef5 0x176195 0xdaff2 0xd98da 0xd8d84 0xd8c9b 0x337c65 0x339626 0x290c 0x28a5 0x1) 
terminate called throwing an exception(lldb) 

我沒能找到任何相關的東西...

回答

0

我發現工作是從體系結構和有效的體系結構列表中刪除armv6並添加armv7s

在Xcode中:

  • 項目導航>您的項目>構建設置選項卡
  • 在搜索框,搜索架構
  • 選擇:標準ARMv7的armv7s

  • 項目導航> CordovaLib。 xcodeproj>構建設置選項卡

  • 在搜索框中,搜索架構
  • 選擇:標準ARMv7的armv7s
  • 在搜索框中搜索有效的架構
  • 刪除的ARMv6
  • 添加armv7s
+0

感謝回答,但unfourtunately我已刪除科爾多瓦2.1.0和安裝科爾多瓦2.0。 0。由於這是一種緊急。但是,我打算再次安裝2.1,並會在執行這些步驟後再次遇到任何問題時通知您。 – webdev