尝试通过单击uibutton事件调用移动到另一个secondviewcontroller

时间:2014-04-12 05:35:53

标签: uiviewcontroller uibutton

我试图通过编程

点击uibutton事件移动到另一个secondviewcontroller
(IBAction)button:(id)sender
{
  UIViewController *homecon=[[UIViewController alloc]initWithNibName:@"loginscreen" bundle:NULL];

    [self segueForUnwindingToViewController:homecon fromViewController:homecon identifier:@"loginscreen"];
    [self.navigationController pushViewController:homecon animated:YES];
}

1 个答案:

答案 0 :(得分:1)

如果您在导航控制器

中,请尝试使用此选项
(IBAction)button:(id)sender 
{

    ViewController *viewController = [[UIViewController alloc]initWithNibName:@"loginscreen" bundle:NULL];

    [self.navigationController pushViewController:viewController animated:YES];
}

否则只是这个

(IBAction)button:(id)sender 
{
     ViewController *viewController = [[UIViewController alloc]initWithNibName:@"loginscreen" bundle:NULL];
    [self presentViewController:viewController animated:YES completion:nil];
}