gpt4 book ai didi

ios - UIScrollView contentInset 不工作

转载 作者:可可西里 更新时间:2023-11-01 04:08:51 54 4
gpt4 key购买 nike

我遇到了一个问题,contentInset 无法让 UIScrollView 使用键盘弹出窗口。它有点有效:出于某种原因我需要大数字(可能高于 View 的高度?)才能做任何事情,尽管 contentInset 的所有文档都显示小数字,如 40.0(例如,对于条形图),或键盘高度。

我通过以下步骤在一个全新的应用程序上重现了这个问题:

  1. 使用 Xcode 新项目创建新的单 View 应用程序
  2. 在 Storyboard上,拖入 ScrollView ,填满整个 View 大小
  3. 在 Storyboard上,将按钮拖入屏幕的最底部(在 ScrollView 内)
  4. 将 ScrollView 链接到 ViewController 中的新属性
  5. 将按钮链接到 ViewController 中的方法
  6. 让按钮的按下方法设置contentInset

这是 ViewController 的代码:

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end

@implementation ViewController
- (IBAction)button:(id)sender {
self.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 600, 0.0);
}
@end

我缺少什么/为什么我需要大数字?

最佳答案

检查 self.scrollView.contentSize 是否设置正确。如果 contentSize.height 为 0(按照您的步骤会出现这种情况),则需要大插图。

尝试将 [self.scrollView setContentSize: CGSizeMake(320, 568)]; 添加到按钮方法中,您会注意到您的插图现在将按预期运行.

关于ios - UIScrollView contentInset 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21143064/

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