Xcode поможет?- "didRotateFromInterfaceOrientation 'undeclared" + "Ожидается";'перед ':' токеном ' - PullRequest
1 голос
/ 21 января 2011

Я пытаюсь создать приложение в XCode, которое переключится на новое представление при повороте телефона из одной ориентации в другую.

Вот код файла "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 ошибки, показанные в вопросе, поэтому он не работает.

1 Ответ

2 голосов
/ 21 января 2011

Вам не хватает блока реализации для -(IBAction)switchview:(id)sender - сделайте его -(IBAction)switchview:(id)sender {} и попробуйте снова.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...