gpt4 book ai didi

ios - 如何在 iOS 环境中隐藏 TextView

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

我是 iOS 编程新手(试图将我的 Android 应用程序转换为 iOS)。我正在使用 Storyboard并想要创建一个 View ,该 View 顶部有一个 ScrollView (内部有一个 ImageView),底部有一个 TextView。如果用户使用纵向方向,这应该是 View 。

现在我希望横向方向的 ViewCOntroller 仅显示 ScrollView 和 ImageView (位于 ScrollView 内)。 TextView 应该隐藏在横向中。是否可以使图像更大,但保持宽高比(在 android:adjustViewBounds 中)?

enter image description here

我该如何处理这个问题?我尝试过使用“自动调整大小”,但结果并不好。

最佳答案

Apple 提供了一种方法,当应用程序改变其方向时调用。

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[textview setHidden:YES];
} else {
[textview setHidden:NO];
}
}

只需将它添加到您的 View Controller 。查看更多 Apple's reference

关于ios - 如何在 iOS 环境中隐藏 TextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25047734/

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