我有一个3 buttons的VC。我完成了对1st button的映射以推送到VC1。当我尝试映射2nd button以推送到VC2时,我的程序崩溃了。为了进行调试,我创建了一个简单的按钮来推送到空VC。它也崩溃了。我不知道发生了什么。 3rd button不会推送到a ny VC

我的故事板

ios -  objective-c -按钮无法推送到VC-LMLPHP

我的密码

@synthesize btnEditProfile;
@synthesize btnChgLang;
@synthesize btnLogOut;

- (void)viewDidLoad {
    [super viewDidLoad];

    //=== Customize the btn
    btnEditProfile.layer.cornerRadius =7.0f;
    btnEditProfile.layer.shadowRadius = 3.0f;
    btnEditProfile.layer.shadowColor = [UIColor blackColor].CGColor;
    btnEditProfile.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
    btnEditProfile.layer.shadowOpacity = 0.5f;
    btnEditProfile.layer.masksToBounds = NO;

    //=== Customize the btn
    btnChgLang.layer.cornerRadius =7.0f;
    btnChgLang.layer.shadowRadius = 3.0f;
    btnChgLang.layer.shadowColor = [UIColor blackColor].CGColor;
    btnChgLang.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
    btnChgLang.layer.shadowOpacity = 0.5f;
    btnChgLang.layer.masksToBounds = NO;

//=== Customize the btn
btnLogOut.layer.cornerRadius =7.0f;
btnLogOut.layer.shadowRadius = 3.0f;
btnLogOut.layer.shadowColor = [UIColor blackColor].CGColor;
btnLogOut.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
btnLogOut.layer.shadowOpacity = 0.5f;
btnLogOut.layer.masksToBounds = NO;
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    ProfileEdit *target = segue.destinationViewController;

    if ([segue.identifier isEqualToString:@"EditProfile"]) {

        target.dataFromProfile = profileData;

    } else {

        target.dataFromProfile = profileData;
    }
}


- (IBAction)btnEditProfile:(id)sender {

    [self performSegueWithIdentifier:@"EditProfile" sender:self];
}

- (IBAction)btnChgLang:(id)sender {

    NSLog(@"What is going on ? ");

    //[self performSegueWithIdentifier:@"ChangeLang" sender:self];
}


- (IBAction)btnLogOut:(id)sender {

    User *userObj = [[User alloc] init];
    [userObj logout];

    //AppDelegate *authObj = (AppDelegate*)[[UIApplication sharedApplication] delegate];
//authObj.authenticated = YES;

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    RootViewController *initView =  (RootViewController*)[storyboard instantiateViewControllerWithIdentifier:@"RootNavigationControllerID"];
    [initView setModalPresentationStyle:UIModalPresentationFullScreen];
    [self presentViewController:initView animated:NO completion:nil];

}


错误

  2018-04-19 17:47:10.846656+0800 SFITNESS[53692:4752813] -[UIViewController setDataFromProfile:]: unrecognized selector sent to instance 0x7fb2f7f8e490
  2018-04-19 17:47:10.867342+0800 SFITNESS[53692:4752813] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDataFromProfile:]: unrecognized selector sent to instance 0x7fb2f7f8e490'
  *** First throw call stack:

最佳答案

你的问题在这里

target.dataFromProfile = profileData;


作为目的地之一

ProfileEdit *target = segue.destinationViewController;


不包含变量

dataFromProfile

关于ios - objective-c -按钮无法推送到VC,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49918004/

10-13 04:39