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个错误,所以它不起作用。
的代码显示不正确:( – Baccalad 2011-01-21 18:14:09
现在这样;-) – 2011-01-21 18:17:01