2013-04-25 48 views
0

我正在從iOS照片庫檢索照片的應用程序。選擇照片時,我想定位一個.xib以顯示可以編輯所選照片的​​界面。意外的接口名稱 - Xcode

然而,編譯失敗因這個錯誤:

"Unexpected interface name 'imageEditorView': expected expression"

下面是代碼:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
    [self dismissViewControllerAnimated:YES completion:^{ 
     [self.parentViewController presentViewController:imageEditorView: animated:YES completion:nil]; 
    }]; 
} 

我有兩個控制器的.h文件正確導入的所有外部組件。任何幫助將不勝感激。

+0

你用這段代碼試圖做什麼?當應用程序啓動你正在解僱? – 2013-04-25 06:55:39

+0

你有答案嗎? – Balu 2013-04-25 07:04:51

+0

self.parentViewController?在應用程序委託? – geraldWilliam 2013-04-25 07:18:31

回答

0

有幾個問題與您的代碼:

  • imageEditorView是一個類的名稱。這不會用作消息參數。你需要傳遞一個對象的引用。

  • imageEditorView之後,在animated之前,您有一個額外的冒號。你需要刪除它。

  • 發送dismissViewControllerAnimated:completion:self裏面application:didFinishLaunchingWithOptions:沒有任何意義。要麼你在應用程序委託中定義了這個方法,它不理解dismissViewControllerAnimated:completion:消息,或者你正在視圖控制器中定義它,在這種情況下application:didFinishLaunchingWithOptions:將不會被調用(除非你編寫代碼明確調用它,這會也很不尋常)。

基於所有這些錯誤,我懷疑你根本不瞭解Objective-C或iOS編程。你需要通過一些教程來學習基礎知識,因爲這些都是非常基本的錯誤。

0

嘗試這樣,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
    { 
     [self dismissViewControllerAnimated:YES completion:^{ 
      [self.parentViewController presentViewController:imageEditorView: animated:YES completion:nil]; 
     // in your code problem must be here 

     }]; 
    } 
imageEditorView *svc = [[imageEditorView alloc]initWithNibName:@"imageEditorView" bundle:nil]; 
[self presentViewController:svc animated:YES completion:NULL]; 
0

你的錯誤是在這裏:

[self.parentViewController presentViewController:imageEditorView: animated:YES completion:nil]; 
----------------------------------------------------------------^ 

你應該使用這樣

[self.parentViewController presentViewController:imageEditorView animated:YES completion:nil]; 
+0

冒號不會導致他引用的錯誤。他引用的錯誤發生是因爲「imageEditorView」是類名,而不是變量名。如果他將其更改爲變量名稱,那麼他將得到錯誤「使用未聲明的標識符」動畫'「(由於冒號)。 – 2013-04-25 07:19:40