rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

Appliaction hang as filterSwitcherView is transformed in willRotateToInterfaceOrientation method and set frame of filterSwitcherView in orientationchaned method #323

Open Tejas-narola opened 8 years ago

Tejas-narola commented 8 years ago

@rFlex

After video is recorded, it play in SCVideoPlayerViewController. I want video in same orientation for each interface orientation, as it was captured. For that i am transforming filterSwitcherView in willRotateToInterfaceOrientation and setting frame in orientationChanged method. But as i rotate device, filterSwitcherView is transformed and filterSwitcherView frame is set in orientationChanged method. but after that UI is getting stuck. This is working fine in iphone 5 for portrait mode only but not in other device.

Code Implemented in willRotateToInterfaceOrientation.

`- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { switch (toInterfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: { _filterSwitcherView.transform = CGAffineTransformMakeRotation(M_PI_2); // 90 degress } break;

    case UIInterfaceOrientationLandscapeRight:
    {
        _filterSwitcherView.transform = CGAffineTransformMakeRotation(M_PI + M_PI_2); // 270 degrees
    }
        break;
    case UIInterfaceOrientationPortraitUpsideDown:
    {
        _filterSwitcherView.transform = CGAffineTransformMakeRotation(M_PI); // 180 degrees
    }
        break;

    default:
    {
        _filterSwitcherView.transform = CGAffineTransformMakeRotation(0.0);
    }
        break;
}

}`

Code implemented in orientationChanged method

`- (void)orientationChanged:(NSNotification *)notification { // NSLog(@"Orientation changed!");

UIInterfaceOrientation toInterfaceOrientation=  [[UIDevice currentDevice] orientation];

if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{

    CGRect filterFrame = _filterSwitcherView.frame;

    filterFrame.origin.x = 0;
    filterFrame.origin.y = 0;
    filterFrame.size.height = SCREEN_HEIGHT;
    filterFrame.size.width = SCREEN_WIDTH;

    _filterSwitcherView.frame = filterFrame;

}
else if(toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
        || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{

    CGRect filterFrame = _filterSwitcherView.frame;
    filterFrame.origin.x = 0;
    filterFrame.origin.y = 0;
    filterFrame.size.height = SCREEN_WIDTH;
    filterFrame.size.width = SCREEN_HEIGHT;
    _filterSwitcherView.frame = filterFrame;
}

}`