Iphone 在MainWindow.xib中加载视图.xib

Iphone 在MainWindow.xib中加载视图.xib,iphone,ios,ipad,uiview,Iphone,Ios,Ipad,Uiview,这可能是一个非常愚蠢的错误,但我已经花了4天多的时间寻找解决方案 很简单,我有MainView.xib和一个名为FirstViewController h/m/xib的视图 在MainWindow.xib中,我添加了一个UIViewController,并将类名更改为FirstViewController,还设置了Nib名称,尽管我已经尝试了这两种方法 我想这一定是和插座有关,但我真的说不出来,因为我是为iOS开发的新手,任何帮助都会有很大帮助 Im使用XCode 3.2和interface b

这可能是一个非常愚蠢的错误,但我已经花了4天多的时间寻找解决方案

很简单,我有MainView.xib和一个名为FirstViewController h/m/xib的视图

在MainWindow.xib中,我添加了一个UIViewController,并将类名更改为FirstViewController,还设置了Nib名称,尽管我已经尝试了这两种方法

我想这一定是和插座有关,但我真的说不出来,因为我是为iOS开发的新手,任何帮助都会有很大帮助

Im使用XCode 3.2和interface builder以及SDK 4.3

AppDelegate

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>


@interface iPadTerritorioV2AppDelegate : NSObject <UIApplicationDelegate> {

    IBOutlet UIWindow *window;
    IBOutlet UIViewController *navigationController;

    NSString *devToken;

    NSString *matricula;
    NSString *campus;

        NSMutableArray *materiasAlumno; //para CCM
        NSMutableArray *busqDir; //para CCM

    NSInteger agendaBadgeNumber;
    NSInteger intramurosBadgeNumber;
    NSInteger notificacionesBadgeNumber;
    NSInteger mapaBadgeNumber;

    NSMutableData *receivedData;
    NSMutableDictionary *listData;

    BOOL yaSeHizoElPrimerFetchBadges;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UIViewController *navigationController;


@property (nonatomic, retain) NSString *devToken;

@property (nonatomic, retain) NSString *matricula;
@property (nonatomic, retain) NSString *campus;

@property (nonatomic, retain) NSMutableArray *materiasAlumno;
@property (nonatomic, retain) NSMutableArray *busqDir;

@property NSInteger agendaBadgeNumber;
@property NSInteger intramurosBadgeNumber;
@property NSInteger notificacionesBadgeNumber;
@property NSInteger mapaBadgeNumber;

@property (nonatomic, retain) NSMutableData *receivedData;
@property (nonatomic, retain) NSMutableDictionary *listData;


@property BOOL yaSeHizoElPrimerFetchBadges;

- (void)fetchBadges;

@end
FirstViewController.h

#import <UIKit/UIKit.h>
#import "Constants.h"
#import "StringDecoding.h"

#define kConnectionBadgeNotifications   0
#define kConnectionLogin                1
#define kConnectionDevToken             2

#define kCCMindex   0
#define kCSFindex   1
#define kMTYindex   2

@interface FirstViewController : UIViewController {

    IBOutlet UISegmentedControl *segmentedCampus;
    IBOutlet UITextField *usernameField;
    IBOutlet UITextField *passwordField;
    IBOutlet UISwitch *remembermeSwitch;
    IBOutlet UIButton *loginButton;
    UIActivityIndicatorView *loginIndicator;

    NSMutableDictionary *listData;
    NSMutableData *receivedData;
    NSInteger connectionID;
}

@property (nonatomic, retain) UISegmentedControl *segmentedCampus;
@property (nonatomic, retain) UITextField *usernameField;
@property (nonatomic, retain) UITextField *passwordField;
@property (nonatomic, retain) UIActivityIndicatorView *loginIndicator;
@property (nonatomic, retain) UISwitch *remembermeSwitch;
@property (nonatomic, retain) UIButton *loginButton;

@property (nonatomic, retain) NSMutableDictionary *listData;
@property (nonatomic, retain) NSMutableData *receivedData;
@property NSInteger connectionID;

- (IBAction)handleNextClick:(id) sender;
- (IBAction)backgroundClick;
- (IBAction)login: (id) sender;

@end

听起来好像你的FirstViewController没有被保留——如果它没有被分配到任何地方的插座,没有任何东西会保留它,它就会消失。在AppDelegate的某个位置添加一个属性(如果您仅此而已),并将其连接到控制器:

@property (nonatomic, retain) IBOutlet UIViewController *firstViewController;

按照惯例,调用视图XXXXXX控制器是错误的。这是一个视图,不是控制器;你有没有试过在Xcode中从头开始创建一个基于视图的项目,看看它的设置如何?@WTP因为我基本上是将一个iPhone应用程序移植到iPad上的,为了一致性,我坚持使用源代码的名称files@Dancreek那可能行,让我检查一下xD@WTPApple有这种命名约定的原因是视图由视图控制器拥有。是,它是一个视图,但它属于视图控制器。因此它是视图控制器.xib文件。它现在崩溃了xD,让我添加我在AppDelegate和FirstViewControllery上得到的内容。如果不清楚,您还需要@synthesis该属性。啊,在这种情况下,我们需要知道崩溃时的错误消息。控制台中没有错误代码,它只是尝试运行并返回到iPad启动屏幕。然后我在IBOutlet中将IUViewController更改为FirstViewController,得到的只是一个黑屏