2011-01-21 49 views
1

我想在Xcode中創建一個應用程序,當手機從一個方向旋轉到另一個方向時,它將切換到新的視圖。Xcode的幫助? - 「'didRotateFromInterfaceOrientation'未聲明」+「預期';'之前':'令牌'

這裏是 「switchviewcontroller.h」 文件代碼:

#import <UIKit/UIKit.h> 

@interface SwitchViewController : UIViewController { 

} 

-(IBAction)switchview:(id)sender; 

@end 

這裏是 「switchviewcontroller.m」 文件代碼:


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

@implementation SwitchViewController 

-(IBAction)switchview:(id)sender 

// 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

的代碼顯示不正確:( – Baccalad 2011-01-21 18:14:09

+0

現在這樣;-) – 2011-01-21 18:17:01

回答

2

您錯過了-(IBAction)switchview:(id)sender 的實現塊 - 將其設置爲-(IBAction)switchview:(id)sender {},然後重試。

相關問題