Adding a button inside a popover

无人久伴 提交于 2020-01-14 06:28:09

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/12309355/adding-a-button-inside-a-popover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!