大佬教程收集整理的这篇文章主要介绍了ios – 从UIView使用presentViewController,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是,它看起来不像[self presentViewController:vc animated:NO completion:NULL];为UIView工作。
如何解决这个问题?
- (void) createtitlebar { CGRect titleBarFrame = CGRectMake(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]; }
做一个视图控制器,您的父视图位于该视图的代表处
ParentView *view = [ParentView new]; ... view.delegate = self;
- (IBACtion)homeButtonPressed:(id)sender { [self.delegate buttonPressed]; }
然后在你的VC实现中
-(void)buttonPressed { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; [vc setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentViewController:vc animated:NO completion:NULL]; }
如果你需要保持这个代码在UIView中,并避免授权,你可以做一个这样的技巧(个人我不喜欢它,但它应该工作)
-(void)buttonPressed{ UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; [vc setModalPresentationStyle:UIModalPresentationFullScreen]; [(UIViewController*)self.nextResonder presentViewController:vc animated:NO completion:NULL]; }
以上是大佬教程为你收集整理的ios – 从UIView使用presentViewController全部内容,希望文章能够帮你解决ios – 从UIView使用presentViewController所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。