问题描述
- iOS在故事板中画好界面 在APPDelegate里面设置启动这个页面的时候 看不见控件
-
AppDelegate 代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ViewController *vc = [ViewController new];
vc.dictUserInfo=@{@"User":[[NSUserDefaults standardUserDefaults] objectForKey:@"User"],
@"Pwd" : [[NSUserDefaults standardUserDefaults] objectForKey:@"Pwd"],
@"IP" : [[NSUserDefaults standardUserDefaults] objectForKey:@"IP"]
};
self.window.rootViewController = vc;
return YES;
}
ViewController.m 代码
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor whiteColor];
self.alertView = [[UIAlertView alloc]initWithTitle:@"失败" message:@"你好" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[self.view addSubview:self.alertView];
self.txtIP.delegate = self;
self.txtUser.delegate = self;
self.txtPwd.delegate =self;
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.txtUser.text =self.dictUserInfo[@"User"];
self.txtPwd.text = self.dictUserInfo[@"Pwd"];
self.txtIP.text = self.dictUserInfo[@"IP"];
}- (IBAction)btnLoginClick:(id)sender {
NSString *user =self.txtUser.text;
NSString *pwd = self.txtPwd.text;
NSString *address = self.txtIP.text;if (user.length>0&&pwd.length>0&&address.length>0) { [[NSUserDefaults standardUserDefaults] setObject:user forKey:@"User"]; [[NSUserDefaults standardUserDefaults] setObject:pwd forKey:@"Pwd"]; [[NSUserDefaults standardUserDefaults] setObject:address forKey:@"IP"]; } else { self.alertView.message=@"参数输入错误!"; [self.alertView show]; }
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
解决方案
你的ViewController 都重新初始化了,当然就没有了
解决方案二:
你虽然启动了这个viewController,但是你没有加载对应的storyboard,所以当然不会显示 的
解决方案三:
没有添加xib,我的博客上有http://blog.csdn.net/u011988082/article/details/46397833
解决方案四:
你的ViewController 都重新初始化了,当然就没有了
你的ViewController 都重新初始化了,当然就没有了
你的ViewController 都重新初始化了,当然就没有了
你的ViewController 都重新初始化了,当然就没有了