gpt4 book ai didi

ios - 如何在 iOS 8 中使用旋转

转载 作者:行者123 更新时间:2023-11-29 02:26:54 26 4
gpt4 key购买 nike

我想要做的是,设备旋转后,UI 需要更改。

这是我尝试过的:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(20.0,850.0,728,90 )];}
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(-10,615.0,728,90 )];}
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(-10,615.0,728,90 )];}}

} completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
{ if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(20.0,850.0,728,90 )];}
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(-10,615.0,728,90 )];}
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
_bannerView = [[GADBannerView alloc] initWithFrame: CGRectMake(-10,615.0,728,90 )];}}


}];

[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

我真的不知道如何正确地做到这一点,所以也许你们可以告诉我?

最佳答案

抱歉,上次回答错误...

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self positionViews]; // set the new frames in here.
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { }];
}

关于ios - 如何在 iOS 8 中使用旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27405040/

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