0
votes

I have an app which has two subviews.I wanna double tap the video view(the top one) to make it fullscreen to display video.(By fullscreen, I mean it should be in landscape mode) So how should I do in the method -(void)handleTapGesture::(UITapGestureRecognizer*)recognizer? I guess, first of all, I should hide status bar and navigation bar; then rotate the video view to make it landscape left/right programmatically. BTW, for some reason, I have to make my app only support portrait mode.Forgive my terrible English, if you don't understand my question clearly, plz leave a comment, thanks. project build settings

enter image description here

Update: I've hided status bar and navigation bar both, but when I make the video view fullscreen, it seems navigation bar and status bar are still there and my video view cannot move up to the top of the screen!

 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[self.navigationController.navigationBar setHidden:YES];

[UIView beginAnimations : @"video full screen" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationBeginsFromCurrentState:YES];

self.videoView.frame = self.view.bounds;
moviewGLView.frame = CGRectMake(0, 0, self.videoView.frame.size.width, self.videoView.frame.size.width*3/4);
moviewGLView.center = self.videoView.center;
videoDefault.center = self.videoView.center;
[UIView commitAnimations];
1

1 Answers

0
votes

add this code in your ViewDidLoad() method

UITapGestureRecognizer *tapOnTopView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(makeTopViewFullScreen)];
tapOnTopView.numberOfTapsRequired = 1;
[topView addGestureRecognizer:tapOnTopView];

add the following function

-(void)makeTopViewFullScreen
{
   [UIView animateWithDuration:0.3 
           animation:^
                   {
                       topViewHeightConstraint = self.view.frame.size.height;
                       bottomViewHeightConstraint = 0;
                       [self layoutIfNeeded];
                   }
           completion:^
                   {
                       //your code to rotate the topView
                   }
}

note that the topViewHeightConstraint and bottomViewHeightConstraint should be outlets connected in IB.

Hope that helps, let me know if you need more help.