gpt4 book ai didi

iOS 8 自定义键盘 UIScrollview 不工作

转载 作者:行者123 更新时间:2023-11-29 12:30:55 25 4
gpt4 key购买 nike

我尝试在自定义键盘 View 中添加 UISchollView,但它显示 View 但不滚动。这是我的代码。我也尝试过 self.view 但它也不起作用。

UIScrollView *scrollview1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
NSInteger viewcount= 8;
for (int i = 0; i <viewcount; i++)
{
CGFloat y = i * 50;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, y,50, 50)];
view.backgroundColor = (i%2==0)?[UIColor greenColor]:[UIColor blueColor];
[scrollview1 addSubview:view];
}
scrollview1.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height *viewcount);
scrollview1.backgroundColor = [UIColor redColor];
scrollview1.pagingEnabled=YES;
[self.inputView addSubview:scrollview1];

enter image description here

最佳答案

UIScrollView 如果其 contentSize 大于其框架大小,则将滚动。因此,请尝试设置其 contentSize 属性并检查是否启用了 userInteraction

希望它能奏效。

关于iOS 8 自定义键盘 UIScrollview 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27752091/

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