gpt4 book ai didi

ios - UIDeviceOrientation ipad

转载 作者:可可西里 更新时间:2023-11-01 03:40:23 24 4
gpt4 key购买 nike

我有以下代码根据方向填充 View 。这总是返回景观。

- (void)setData:(BCPlaylist *)list  {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown){
NSLog(@"portrait");
[self setPlaylist:list];
[self renderPlaylist];
[activity stopAnimating];
}else{
NSLog(@"landscape");
[self setPlaylist:list];
[self renderPlaylistOne];
[activity stopAnimating];
}
}

我在 - (void)animateRotation:(UIInterfaceOrientation)interfaceOrientation 中正确更改 View
持续时间:(NSTimeInterval)持续时间{
但这在更改播放列表时已经处于横向或纵向时不起作用。

最佳答案

不要使用 [[UIDevice currentDevice] orientation] 检查方向,而是使用 statusbar orientation 来获取准确的方向。

    UIDeviceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

关于ios - UIDeviceOrientation ipad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7413084/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com