Adding a button inside a popover

2019-06-14 13:08发布

Is it possible inside Xcode to add a button inside a popover that will take the user to a new view?

1条回答
▲ chillily
2楼-- · 2019-06-14 13:52

Yes.

[myPopOver.contentViewController.view addSubview:myButton];
[myButton addTarget:self action:@selector(goToNextView) forControlEvents:UIControlEventTouchUpInside];

- (void)goToNextView
{
 //if you are using xibs use this line
    UIViewController *controller = [[UIViewController alloc] initWithNibName:@"myXib" bundle:[NSBundle mainBundle]];
//if you are using storyboards use this line
    UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"myViewControllersID"];

//to present the controller modally use this
    [self presentViewController:controller animated:YES completion:nil];
//or if you are pushing to this controller using a navigation controller use this
    [self.navigationController pushViewController:controller animated:YES];
}
查看更多
登录 后发表回答