【问题标题】:How to make Scrollable the Storyboard Scrollview?如何使 Storyboard Scrollview 可滚动?
【发布时间】:2015-09-09 14:01:25
【问题描述】:

我正在使用故事板滚动视图,但它没有滚动,如何使它成为可滚动的。

这是我的代码

-(void)scrollView
{
    self.scrollViewBtn.pagingEnabled=YES;
    self.scrollViewBtn.scrollEnabled=YES;
    for(int i=0;i<[[arrFullSubCategory valueForKey:@"name"]count];i++)
    {
        CGRect frame;
        frame.origin.x=self.scrollViewBtn.frame.size.width *i;
        frame.origin.y=0;
        frame.size=self.scrollViewBtn.frame.size;
        UIButton *btn=[[UIButton alloc]initWithFrame:frame];
        [btn setTitle:[NSString stringWithFormat:@"%@",[[arrFullSubCategory objectAtIndex:i] valueForKey:@"name"]] forState:UIControlStateNormal];
        [self.scrollViewBtn addSubview:btn];
        btn.backgroundColor=[UIColor colorFromHexString:@"#ffc400"];
        btn.userInteractionEnabled=YES;
        length = [[arrFullSubCategory valueForKey:@"name"] count];


    }
    self.scrollViewBtn.contentSize=CGSizeMake(self.scrollViewBtn.frame.size.width *length, self.scrollViewBtn.frame.size.height-60);
}

【问题讨论】:

  • scrollViewBtn 上的 userInteractionEnabled 了吗?
  • 是的,它的启用和委托也完美设置。 @akashsr
  • 你在哪里声明长度变量?
  • 你设置scrollview水平滚动了吗?
  • 记录你的内容大小,如果小于滚动视图,它不会滚动。内容大小应大于滚动视图

标签: ios objective-c uiscrollview uiscrollviewdelegate


【解决方案1】:

你检查过属性检查器吗?

您还可以使用 Xcode 布局调试工具检查按钮是否正确添加

Xcode Debugging Layout

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多