我正在为我的 iOS 应用程序创建一个标题栏,并在 UIView 中创建它。我遇到的唯一问题是“主页按钮”。当home键被按下时,需要跳转到首页,也就是ViewController。
但是,它似乎不适[self presentViewController:vc animated:NO completion:NULL];
用于 UIView。
我该如何解决这个问题?
- (void) createTitlebar {
CGRect titleBarFrame = CGRectMake(0, 0, 320, 55);
//Create the home button on the top right of the page. When clicked, it will navigate to the home page of the application
homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
homeButton.frame = CGRectMake(275, 10, 40, 40);
[homeButton setTag:1];
[homeButton setImage:[UIImage imageNamed:@"homeIcon.png"] forState:UIControlStateNormal];
[homeButton addTarget:self action:@selector(homeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:homeButton];
}
- (IBAction)homeButtonPressed:(id)sender{
//Transition to the submit button page
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:vc animated:NO completion:NULL];
}