[英]Load a view .xib in MainWindow.xib
It`s probably a very silly mistake, but I've spent over 4 days looking for a solution for this.这可能是一个非常愚蠢的错误,但我花了 4 多天的时间寻找解决方案。
It is very simple, I´ve got my MainView.xib and a view called FirstViewController (h/m/xib).这很简单,我有我的 MainView.xib 和一个名为 FirstViewController (h/m/xib) 的视图。
In MainWindow.xib I add a UIViewController and change the class name to FirstViewController and set the Nib name also (altouhg I've tried both ways).在 MainWindow.xib 中,我添加了一个 UIViewController 并将 class 名称更改为 FirstViewController 并设置 Nib 名称(尽管我已经尝试了两种方式)。
I guess it has to do something with outlets, but I can`t really tell, as I am a newbie developing for iOS, any help wil REALLY help a lot.我想它必须与网点有关,但我不能说清楚,因为我是为 iOS 开发的新手,任何帮助都会有很大帮助。
Im using XCode 3.2 and interface builder, with SDK 4.3我正在使用 XCode 3.2 和界面生成器,以及 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第一视图控制器.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
It sounds like your FirstViewController isn't being retained - if it's not assigned to an outlet anywhere, nothing's retaining it and it'll just disappear.听起来您的 FirstViewController 没有被保留 - 如果它没有分配给任何地方的插座,则没有任何东西保留它,它就会消失。 Add a property somewhere (your AppDelegate, perhaps, if that's all you've got) and connect it to the controller:
在某处添加一个属性(也许是您的 AppDelegate,如果这就是您所拥有的)并将其连接到 controller:
@property (nonatomic, retain) IBOutlet UIViewController *firstViewController;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.