如何修复'[LoginVC viewControllers]:发送到实例的无法识别的选择器'

时间:2017-08-14 07:17:21

标签: objective-c iphone xcode uisplitviewcontroller

我试图为iphone使用拆分视图控制器,但是当我为AppDelegate.m添加如下代码时,我收到错误。我的应用程序还使用了一个使用文件LoginVC的登录系统,该文件之前工作正常。

[此处的故事板图片] [1]:https://i.stack.imgur.com/GRosR.png

#import "AppDelegate.h"
#import "RightVC.h"
#import "LeftVC.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

(BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UISplitViewController *splitViewController = (UISplitViewController 
*)self.window.rootViewController;


UINavigationController *leftNavController = 
[splitViewController.viewControllers objectAtIndex:0];


LeftVC *leftViewController = (LeftVC *)[leftNavController 
topViewController];


RightVC *rightViewController = [splitViewController.viewControllers 
objectAtIndex:1];


Recipe *firstRecipe = [[leftViewController recipes] objectAtIndex:0];

[rightViewController setRecipe:firstRecipe];

return YES;
}

我的LoginVC.m

#import "LoginVC.h"

@interface LoginVC ()

@end

@implementation LoginVC

- (void)viewDidLoad {
    [super viewDidLoad];

    self.checkLogin = [[LoginService alloc]init];

    // Do any additional setup after loading the view.
}

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

-(void) alertStatus:(NSString *)msg :(NSString *) title: (int) tag {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title 
message:msg delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, 
nil];
    alertView.tag = tag;
    [alertView show];
}


/*
#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.
}
*/

- (IBAction)btnLogin:(id)sender {
    if([self.txtUsername.text isEqualToString:@""] || [self.txtPassword.text 
isEqualToString:@""]) {
        [self alertStatus:@"Username and/or Password cannot be blank!" 
:@"Sign in Failed" :0];
    } else{
        self.checkLogin.strUsername = self.txtUsername.text;
        self.checkLogin.strPassword = self.txtPassword.text;

        BOOL lgs = self.checkLogin.success;

        if(lgs==1){
            [self performSegueWithIdentifier:@"ShowMain" sender:self];

        }else{
            [self alertStatus:@"Wrong Username and/or Password!" :@"Sign in 
Failed":0];
        }
    }

}

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.txtUsername resignFirstResponder];
    [self.txtPassword resignFirstResponder];
    [[self.view window] endEditing:YES];
}

@end

一直试图修复,但我所拥有的只是网上的一些拆分视图指南

0 个答案:

没有答案