Xcode错误 - 未知类型名称' home'

时间:2014-04-19 16:03:46

标签: ios objective-c xcode

这是我关于stackoverflow的第一个问题。干杯!

请从以下链接查看我的代码。我将appdelegate.h,appdelegate.m,viewcotroller.h和.m复制粘贴到文本文档中以供查看。

http://www.mediafire.com/view/85614p44t8eiqif/HomePageViewController.rtf

我将在下面详细解释我的问题。

我正在尝试通过代码以较小的比例重新创建UICatalogue。我是一名应用开发实习生。这是我到目前为止所做的。

请记住,我对Xcode和Objective-C的了解非常有限。我正在使用Xcode 5.1.1

  • 我在AppDelegate.h中为主页视图控制器“HomePageViewController”创建了一个实例变量(HPVC)

  • 我已将此HPVC设置为rootviewcontroller。

  • 声明并定义了一些实例变量。

*但到目前为止,我已经陷入了一个循环中。

我知道导入已经在循环中结束了。但我无法解决它。

请检查一下并给我一个答案。我可以开始我的项目如果我能清除这个障碍。

以下是错误的屏幕截图

http://www.mediafire.com/view/yjmwbb2dcb7rymd/Error.png

//
//  AppDelegate.h
//  NewUICatalogue1
//
//  Created by Roshith Balendran on 18/04/14.
//  Copyright (c) 2014 Roshith Balendran. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "HomePageViewController.h"


@interface AppDelegate : UIResponder <UIApplicationDelegate>

{
    HomePageViewController *HPVC;

}


@property (strong, nonatomic) UIWindow *window;

@end





    //
    //  AppDelegate.m
    //  NewUICatalogue1
    //
    //  Created by Roshith Balendran on 18/04/14.
    //  Copyright (c) 2014 Roshith Balendran. All rights reserved.
    //

    #import "AppDelegate.h"


    @implementation AppDelegate


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.

        HPVC=[[HomePageViewController alloc]initWithNibName:@"HomePageViewController" bundle:nil];
        self.window.rootViewController=HPVC;

        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    }

    - (void)applicationWillResignActive:(UIApplication *)application
    {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    - (void)applicationWillEnterForeground:(UIApplication *)application
    {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    - (void)applicationWillTerminate:(UIApplication *)application
    {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

    @end


    //
    //  HomePageViewController.h
    //  NewUICatalogue1
    //
    //  Created by Roshith Balendran on 18/04/14.
    //  Copyright (c) 2014 Roshith Balendran. All rights reserved.
    //

    #import <UIKit/UIKit.h>

    @interface HomePageViewController : UIViewController

    //Background Images for all the Views.
    @property(nonatomic,strong) UIImageView *HomePageBG;
    @property(nonatomic,strong) UIImageView *Page1ButtonBG;
    @property(nonatomic,strong) UIImageView *Page2ControlsBG;
    @property(nonatomic,strong) UIImageView *Page3TextFieldBG;
    @property(nonatomic,strong) UIImageView *Page4TextView;
    @property(nonatomic,strong) UIImageView *Page5Images;
    @property(nonatomic,strong) UIImageView *Page6Segments;
    @property(nonatomic,strong) UIImageView *Page7Toolbar;
    @property(nonatomic,strong) UIImageView *Page8Alerts;
    @property(nonatomic,strong) UIImageView *Page9Transitions;

    //Home Page Elements.
    @property(nonatomic,strong) UILabel *lblHomePageHeader;
    @property(nonatomic,strong) UILabel *lblHomePageWelcome;
    @property(nonatomic,strong) UIButton *BtnPage1;
    @property(nonatomic,strong) UIButton *BtnPage2;
    @property(nonatomic,strong) UIButton *BtnPage3;
    @property(nonatomic,strong) UIButton *BtnPage4;
    @property(nonatomic,strong) UIButton *BtnPage5;
    @property(nonatomic,strong) UIButton *BtnPage6;
    @property(nonatomic,strong) UIButton *BtnPage7;
    @property(nonatomic,strong) UIButton *BtnPage8;
    @property(nonatomic,strong) UIButton *BtnPage9;
    @property(nonatomic,strong) UIButton *BtnChangeBGColor;





    //Future Update. Add Button to change all button colors in Home Page.

    @end


    //
    //  HomePageViewController.m
    //  NewUICatalogue1
    //
    //  Created by Roshith Balendran on 18/04/14.
    //  Copyright (c) 2014 Roshith Balendran. All rights reserved.
    //

    #import "HomePageViewController.h"

    @interface HomePageViewController ()

    @end

    @implementation HomePageViewController

    @synthesize HomePageBG;
    @synthesize Page1ButtonBG;
    @synthesize Page2ControlsBG;
    @synthesize Page3TextFieldBG;
    @synthesize Page4TextView;
    @synthesize Page5Images;
    @synthesize Page6Segments;
    @synthesize Page7Toolbar;
    @synthesize Page8Alerts;
    @synthesize Page9Transitions;

    @synthesize lblHomePageHeader;
    @synthesize lblHomePageWelcome;
    @synthesize BtnPage1;
    @synthesize BtnPage2;
    @synthesize BtnPage3;
    @synthesize BtnPage4;
    @synthesize BtnPage5;
    @synthesize BtnPage6;
    @synthesize BtnPage7;
    @synthesize BtnPage8;
    @synthesize BtnPage9;
    @synthesize BtnChangeBGColor;



    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }

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

        //Home Page Background image added.
        HomePageBG=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
        HomePageBG.image=[UIImage imageNamed:@"Red"];
        [self.view addSubview:HomePageBG];


    }

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

    /*
    #pragma mark - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */

    @end

1 个答案:

答案 0 :(得分:0)

一切都是正确的,但你忘了在app delegate.m类上导入#import“HomePageViewController.h”