如何让Scrollable成为Storyboard Scrollview?

时间:2015-09-09 14:01:26

标签: ios objective-c uiscrollview uiscrollviewdelegate

我正在使用storyboard scrollview但它没有滚动,如何使其成为可滚动的。

这是我的代码

-(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);
}

1 个答案:

答案 0 :(得分:2)

您是否检查了属性检查器?

Attributes inspector

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

Xcode Debugging Layout