简体   繁体   English

在弹出框内添加按钮

[英]Adding a button inside a popover

是否可以在Xcode内部在弹出窗口内添加一个按钮,以将用户带到新视图?

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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM