Xcode 是否应自动旋转指针面方向不';返回到肖像时不要开火

Xcode 是否应自动旋转指针面方向不';返回到肖像时不要开火,xcode,device-orientation,Xcode,Device Orientation,活动内容如下: - (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation { [self setupScrollView]; return YES; } 每当旋转设备时,我都会设置我的UIScrollView,这样里面的东西总是“右”向上 除非设备从横向旋转回纵向(右侧向上),否则此操作有效,断点验证是否未调用shouldAutorotateTo

活动内容如下:

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{    
    [self setupScrollView];
    return YES;
}
每当旋转设备时,我都会设置我的
UIScrollView
,这样里面的东西总是“右”向上


除非设备从横向旋转回纵向(右侧向上),否则此操作有效,断点验证是否未调用
shouldAutorotateToInterfaceOrientation
。因此,当设备返回到纵向时,
UIScrollView
内容是横向的。如何解决此问题?

仍不确定上述操作为何无效,但以下操作似乎有效:

- (void)viewDidLoad {
[super viewDidLoad];  

//for some reason shouldAutorotateToInterfaceOrientation isn't firing when returning to portrait so we need to register for notifications
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupScrollView) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];  

//for some reason shouldAutorotateToInterfaceOrientation isn't firing when returning to portrait so we need to register for notifications
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupScrollView) name:UIDeviceOrientationDidChangeNotification object:nil];
}