[英]Orientation Working on simulator but not on device for ios7
我已經看到同一問題的多個副本。但它不支持我的原因。
我嘗試將導航控制器的添加類別歸類為導航控制器,並且當我嘗試所有這些方法時,對Navigationcontroller和View Controller均應調用shouldAutoRotate和supportedInterfaceOrientations方法,但設備僅停留在縱向視圖中。
#import "UINavigationController+Rotation.h"
@implementation UINavigationController (Rotation)
- (BOOL)shouldAutorotate {
BOOL result = self.topViewController.shouldAutorotate;
return result;
}
- (NSUInteger)supportedInterfaceOrientations {
NSUInteger result = self.topViewController.supportedInterfaceOrientations;
return result;
}
@end
我做錯了什么嗎?
以viewdidload
形式調用此方法:
-(void)rotateCameraView {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name:
UIDeviceOrientationDidChangeNotification object: nil];
}
旋轉設備時,此方法將自動調用
-(void)deviceOrientationDidChange:(NSNotification *)notification {
//Obtaining the current device orientation
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
//Ignoring specific orientations
if (orientation == UIDeviceOrientationFaceUp
|| orientation == UIDeviceOrientationFaceDown || orientation ==
UIDeviceOrientationUnknown) { return; }
if ((UIDeviceOrientationIsPortrait(orientation)
||UIDeviceOrientationIsPortrait(orientation)) ||
(UIDeviceOrientationIsLandscape(orientation) ||
UIDeviceOrientationIsLandscape(orientation))) {
//still saving the current orientation
currentOrientation = orientation; } [self
performSelector:@selector(orientationChangedMethod) withObject:nil
afterDelay:0];
}
-(void)orientationChangedMethod
{
switch (currentOrientation) {
case UIDeviceOrientationPortrait:
if (isOrientationEffect==YES)
{
appDelegate.imagePickerController.cameraViewTransform = CGAffineTransformMakeRotation(M_PI);
// if (!isPurchased)
// {
//
// [self buttonFrameWithIad];
// }
// else
// {
// [self buttonFrameWithoutIad];
// }
[self MakeTransformRotation];
}
[UIView beginAnimations:@"rotateView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.35f];
camDefaultImg.transform = CGAffineTransformMakeRotation(0);
[UIView commitAnimations];
break;
case UIDeviceOrientationLandscapeLeft:
if (isOrientationEffect==YES)
{
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.