gpt4 book ai didi

ios - UIScrollView 内的 UIButton 禁用滚动

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:11:53 24 4
gpt4 key购买 nike

将一个按钮拖到我的 ScrollView 后,窗口不再滚动!如果我删除按钮,现在可以滚动了。

以前有人遇到过这个问题吗?

//ScrollViewController.h
@property (weak, nonatomic) IBOutlet UIScrollView *scroller;


//ScrollViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

[self.scroller setScrollEnabled:YES];
[self.scroller setContentSize:CGSizeMake(320, 700)];
}

enter image description here

最佳答案

实际上,它只是在将代码移动到 viewDidLayoutSubiews 之后才起作用。

有人可以解释为什么这有效吗?

- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.scroller setScrollEnabled:YES];
[self.scroller setContentSize:CGSizeMake(320, 700)];
}

关于ios - UIScrollView 内的 UIButton 禁用滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18047012/

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