2011-01-21 1 views
1

Xcodeでアプリケーションを作成しようとしています。別のここでXcodeのヘルプ - 'secondview'クラスの実装が正しくありません+ '-switchview:'のメソッド定義が見つかりません

は "switchviewcontroller.h" ファイルのコードです:


#import <UIKit/UIKit.h> 

@interface SwitchViewController : UIViewController { 

} 

-(IBAction)switchview:(id)sender; 

@end 
----------------------------------------------------------------- 

And here is the "switchviewcontroller.m" file code: 

---------------------------------------- 
#import "SwitchViewController.h" 
#import "secondview.h" 

@implementation SwitchViewController 

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return YES; 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
     (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) 
    {  
     [[secondview alloc] initWithNibName:@"secondview" bundle:[NSBundle mainBundle]]; 
    } 

} 

私は2つの警告が質問に示し、それはまた、動作しません取得します。

+0

コードは、私はあなたが言ったことをやったと私は2つのエラーが出て、右ennuikiller – Baccalad

+0

おかげで正しく表示されないように:「」didRotateFromInterfaceOrientation「(この機能で最初に使用する)宣言されていない」+「期待';' before: 'トークン' – Baccalad

答えて

1

よく定義されているメソッド定義は正確には.....あなたが投稿したコードでは、switchviewメソッドはありません。誤った実装エラーメッセージは、secondviewクラスがuiviewに適合しないことを意味します。 [OK]を

0

あなたは

-(IBAction)switchview:(id)sender; 

を宣言していますが、それを実装していませんでした。あなたの.mファイルで

、あなたは毎回1つのsecondviewインスタンスをリークしますので、ビューを回転させたときにいつでもsecondviewのインスタンスを作成しているようにも、それが見えます

-(IBAction)switchview:(id)sender 
{ 
    //here is the implementation of the switch view method 
} 

を追加インターフェイスの向きが変わります。

+0

を見て作るためのすべての – Baccalad

関連する問題