讓人痛恨的xcode錯誤提示信息! 以及為什么不能將A.h文件 在B.h文件#import 而只能在B.m文件中#import呢?


 

在調試程序時,遇到如下兩條信息:

Expected identifier

Expected ';' after method prototype

原因:A.h文件  在B.h文件#import 導致A.h文件報出如上錯誤提示,只要將聲明文件寫在B.m文件中即可解決上述問題。為什么?

B.h  文件

#import <UIKit/UIKit.h>
@interface WelcomeViewController : UIViewController

@end

B.m文件

#import "WelcomeViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "IndexViewController.h"
#import "InterfaceHelper.h"     //要引入的那個.h文件

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

@interface WelcomeViewController ()

@end

@implementation WelcomeViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    

    [self performSelector:@selector(GoToViewController) withObject:nil afterDelay:1]; //1秒后,進入應用程序的主界面
    
    [InterfaceHelper initInterfaceHelper];
    NSUserDefaults *configData = [NSUserDefaults standardUserDefaults];
    NSLog(@"%@",[configData objectForKey:@"initStart"]);

}

-(void)GoToViewController
{
    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 0.7 ;  // 動畫持續時間(秒)
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.type = kCATransitionFade;//淡入淡出效果
    [[self.view layer]addAnimation:animation forKey:@"animation"];
    
//    MainViewController *myMainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
//    [self.view addSubview:myMainViewController.view];
    
    if (iPhone5) {
       IndexViewController *myIndexViewController = [[IndexViewController alloc]initWithNibName:@"IndexViewController_ip5" bundle:nil];
        [self.view addSubview:myIndexViewController.view];
    }else{
       IndexViewController *myIndexViewController = [[IndexViewController alloc]initWithNibName:@"IndexViewController" bundle:nil];
        [self.view addSubview:myIndexViewController.view];
    }
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    return NO;
}

@end

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM