如何在iOS中为多个动态按钮添加自动布局?

如何在iOS中为多个动态按钮添加自动布局?,ios,objective-c,xcode6,Ios,Objective C,Xcode6,我创建了83个按钮动态现在我想设置自动布局。怎样 我可以为它编码吗? 我实现了以下代码来生成动态按钮 -(void)DynamicButton { int yPossion = 150, xPossion = 44; int temp = 0; UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame]; [self.view addSubview:scrollV

我创建了83个按钮动态现在我想设置自动布局。怎样 我可以为它编码吗? 我实现了以下代码来生成动态按钮

    -(void)DynamicButton
    {

   int yPossion = 150, xPossion = 44; int temp = 0;
   UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];
   [self.view addSubview:scrollView];


    for (int i = 0; i<83; i++){

    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [aButton setTranslatesAutoresizingMaskIntoConstraints:YES];

    [aButton setBackgroundColor:[UIColor blackColor]];
    [aButton setBackgroundImage:[UIImage imageNamed:@"icon-menu.png"] forState:UIControlStateNormal];

    [aButton setTitle:[NSString stringWithFormat:@" %d",i] forState:UIControlStateNormal];

    [aButton setFrame:CGRectMake(xPossion, yPossion, 70, 60)];
    aButton.highlighted=YES;

    [scrollView addSubview:aButton];


    xPossion += aButton.frame.size.width+35;
    temp++;
    if (temp==3) {
        yPossion = aButton.frame.origin.y+aButton.frame.size.height+20;
        temp = 0;
        xPossion = 44;
       yPossion += aButton.frame.size.width-15;
    [scrollView setContentSize:CGSizeMake(scrollView.frame.size.width ,yPossion-50)];
    }

      }


    }

how to add auto layout for multiple dynamic buttons in iOS?
我为标签做了以下工作: 在纯布局中完成

APP_DELEGATE.labelWidth = 0;
for (NSInteger i = 0;i < self.industry.numberOfColumns-1; i++) {

        UIFont *font = [UIFont fontWithName:@"Helvetica Neue" size:16];

        NSDictionary *userAttributes = @{NSFontAttributeName: font,
                                         NSForegroundColorAttributeName: ECONOMY_TABLE_ROW_TEXT_COLOR};

        NSString *text = [NSString stringWithFormat:@"%@",[[self.industry.data objectAtIndex:APP_DELEGATE.rowCount] objectAtIndex:i]];            

        const CGSize textSize = [text sizeWithAttributes: userAttributes];

        [self addStringWithWidth:textSize.width withHeight:textSize.height
                    withLeftEdge:0
                         witText:text];
    }


- (void)addStringWithWidth:(NSInteger)width
            withHeight:(NSInteger)height
          withLeftEdge:(NSInteger)leftEdge
               witText:(NSString *)labelString {


self.indicatorLabel = [UIUtils createLabelWithText:nil
                                  withTextColorRGB:ECONOMY_TABLE_ROW_TEXT_COLOR
                                 withTextAlignment:NSTextAlignmentRight
                                          withFont:@"Helvetica Neue"
                                       andFontSize:16];

[self.contentView addSubview:self.indicatorLabel];

self.indicatorLabel.lineBreakMode = NSLineBreakByWordWrapping;

self.indicatorLabel.numberOfLines = 0;

[self.indicatorLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10.0f];
[self.indicatorLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:10.0f];
[self.indicatorLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20+APP_DELEGATE.labelWidth];
[self.indicatorLabel autoSetDimension:ALDimensionWidth toSize:self.width];

self.indicatorLabel.text = labelString;

APP_DELEGATE.labelWidth = APP_DELEGATE.labelWidth + self.width+20;

}

在三列中按列显示我想要按钮?如何从数据库中获取数据你得到了答案…你能为这个问题发布你的方法吗。。。