2011-07-03 9 views
1

iPhone iOSアプリケーションを作成しています。私はタブバーのコントローラに3つのタブがあります。私は、iOSシミュレータでタブバーコントローラ上の3番目のタブをタップすると、iOSのシミュレータは消え、私は上の緑のハイライトとmain.mファイルを示しています:タブバータップでビルドエラーが発生するのはなぜですか?

int retVal = UIApplicationMain(argc, argv, nil, nil); 

ビルドエラー状態それ:スレッド1:このプログラムは、信号を受信:SIGABRT

私は、画面の一番下にあるビルド出力ウィンドウを見れば、私は次のテキストを参照してください。

GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011) 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "x86_64-apple-darwin".Attaching to process 4283. 
**2011-07-03 12:45:37.114 Cypher Bot[4283:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e1b190> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key portraitView.' 
*** Call stack at first throw: 
(
     0 CoreFoundation      0x00dce5a9 __exceptionPreprocess + 185 
     1 libobjc.A.dylib      0x00f22313 objc_exception_throw + 44 
     2 CoreFoundation      0x00dce4e1 -[NSException raise] + 17 
     3 Foundation       0x007a0677 _NSSetUsingKeyValueSetter + 135 
     4 Foundation       0x007a05e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285 
     5 UIKit        0x0021c30c -[UIRuntimeOutletConnection connect] + 112 
     6 CoreFoundation      0x00d448cf -[NSArray makeObjectsPerformSelector:] + 239 
     7 UIKit        0x0021ad23 -[UINib instantiateWithOwner:options:] + 1041 
     8 UIKit        0x0021cab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 
     9 UIKit        0x000d2628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70 
     10 UIKit        0x000d0134 -[UIViewController loadView] + 120 
     11 UIKit        0x000d000e -[UIViewController view] + 56 
     12 UIKit        0x000e2f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120 
     13 UIKit        0x000e1aaa -[UITabBarController transitionFromViewController:toViewController:] + 64 
     14 UIKit        0x000e38a2 -[UITabBarController _setSelectedViewController:] + 263 
     15 UIKit        0x000e3711 -[UITabBarController _tabBarItemClicked:] + 352 
     16 UIKit        0x000204fd -[UIApplication sendAction:to:from:forEvent:] + 119 
     17 UIKit        0x00222ce6 -[UITabBar _sendAction:withEvent:] + 422 
     18 UIKit        0x000204fd -[UIApplication sendAction:to:from:forEvent:] + 119 
     19 UIKit        0x000b0799 -[UIControl sendAction:to:forEvent:] + 67 
     20 UIKit        0x000b2c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
     21 UIKit        0x000b0750 -[UIControl sendActionsForControlEvents:] + 49 
     22 UIKit        0x000204fd -[UIApplication sendAction:to:from:forEvent:] + 119 
     23 UIKit        0x000b0799 -[UIControl sendAction:to:forEvent:] + 67 
     24 UIKit        0x000b2c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
     25 UIKit        0x000b17d8 -[UIControl touchesEnded:withEvent:] + 458 
     26 UIKit        0x00044ded -[UIWindow _sendTouchesForEvent:] + 567 
     27 UIKit        0x00025c37 -[UIApplication sendEvent:] + 447 
     28 UIKit        0x0002af2e _UIApplicationHandleEvent + 7576 
     29 GraphicsServices     0x01007992 PurpleEventCallback + 1550 
     30 CoreFoundation      0x00daf944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
     31 CoreFoundation      0x00d0fcf7 __CFRunLoopDoSource1 + 215 
     32 CoreFoundation      0x00d0cf83 __CFRunLoopRun + 979 
     33 CoreFoundation      0x00d0c840 CFRunLoopRunSpecific + 208 
     34 CoreFoundation      0x00d0c761 CFRunLoopRunInMode + 97 
     35 GraphicsServices     0x010061c4 GSEventRunModal + 217 
     36 GraphicsServices     0x01006289 GSEventRun + 115 
     37 UIKit        0x0002ec93 UIApplicationMain + 1160 
     38 Cypher Bot       0x00002889 main + 121 
     39 Cypher Bot       0x00002805 start + 53 
     40 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 
sharedlibrary apply-load-rules all 
Current language: auto; currently objective-c 
(gdb)** 
> 

を私はちょうどこの前に第三ビューコントローラに加えられた変更はなかったです:

  1. メモリ警告イベント
  2. あなたはSMSアプリを開くことができる機能を追加風景
  3. のサポートを追加します(私は削除して、その、その後、私はプロジェクトを実行したが、何も起こらなかった)

EDIT: Iは、ヘッダファイルが含まれている:

#import <UIKit/UIKit.h> 


@interface ThirdViewController : UIViewController { 
    IBOutlet UIView *landscapeView; 
    IBOutlet UIView *portraitView; 

} 

@property (nonatomic, retain) IBOutlet UIView *landscapeView; 

@property (nonatomic, retain) IBOutlet UIView *portraitView; 
@end 

を@propertiesを@synthesizeで使用され、エラーがない、またはプロジェクトの警告。

EDIT 2:私はportraitViewとlandscapeViewに関連するすべてのものを削除しているし、今私はそれを実行して、私はもっとタップしたときに、私は次を得る:

**Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Spencer/Library/Application Support/iPhone Simulator/4.3.2/Applications/1E0A4C15-2143-442D-A8FC-4AE36CFC90E4/Cypher Bot.app> (loaded)' with name 'ThirdViewController.xib''** 

私が間違って何をしているのですか? 3番目のタブをタップできないのはどうしてですか?

ご協力いただきましてありがとうございます。ありがとう!

+0

'[setValue:forUndefinedKey:]:このクラスはキーのコード値に対応していません。「portraitView」はエラーのように見えますが、どこでもportraitViewという変数を使用していますか? –

+0

はいIBOutlet UIView * portraitViewを使用しています。私も@propertyと@synthesizeで使用します。 –

+0

私はヘッダファイルを読みましたが、何も問題がないようです.xibファイルにはすべてのアウトレットがリンクされています。それ以外に何ができるのか分かりません。 –

答えて

4

あなたのnibファイルは、UIViewControllerのportraitViewという名前のコンセントに何かをバインドしようとしますが、UIViewControllerにはこのようなプロパティはありません。私はあなたがIBに移動し、そのビューコントローラのクラスをあなたのアプリケーションのカスタムUIViewControllerサブクラスに変更する必要があると思います。ここで

1

IB Snapshot

Interface Builderで私の見解です。 "File's Owner"は、対応するView Controllerに設定する必要があります。ここでは、 "ThirdViewController"がここに表示されます。正しいView Controllerにリンクしていることを確認してください。

また、このビューコントローラをタブバーに追加するコードを確認してください。 UIViewControllerまたはThirdViewControllerを初期化していますか?それがThirdViewControllerであることを確認してください。

+0

それは素晴らしい解決策のように聞こえましたが、それは私のために働きません。 XcodeがUIViewControllerを初期化している場所はどこですか? –

+0

タブバーコントローラーを作成すると、タブとして機能するビューコントローラーが表示されます。これはおそらく、アプリの起動時に発生します。あなたのコードのどこかにあります。ここでは、 'UIViewController'だけでなく、' ThirdViewController 'を作成していることを確認する必要があります。 –

+0

ブラッドリー 私はあなたが提案したすべてを試しました。私が間違っていなければならないことがあります。私はタブバーテンプレートを使用し、UIViewControllerサブクラスを追加し、それらをすべて独自のペン先とメインウィンドウのnibとアプリケーションのデリゲートにリンクしています。私は新しいプロジェクトを開始し、すべてのものをプロジェクトにコピーするだけですか?私は他に何かできますか? –

0

インタフェースビルダーのビューをその変数にドラッグした後に、その変数の名前が変更された可能性があります。修正するには、再度ドラッグする必要があります。おそらく、そのプロパティのinterfacebuilderに説明マークがあります。

関連する問題