0

I am creating 5 buttons dynamically in my project.
Now I want code for each of the dynamic buttons to move to the next screen when I click a button.
If you have sample example same like my requirement then please post here.

I know its very easy for drag and drop control to connect next form but I want to do that dynamically.
Code I have so far:

for (i = 1; i <= 5; i++) {
    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
    aButton.frame = CGRectMake(xCoord, yCoord, buttonWidth, buttonHeight);
    [
        aButton addTarget:self action:@selector(whatever:)    
        forControlEvents:UIControlEventTouchUpInside
    ];
    [scrollView addSubview:aButton];
    yCoord += buttonHeight + buffer;
}
Hashbrown
  • 12,091
  • 8
  • 72
  • 95
user3228492
  • 21
  • 1
  • 4

1 Answers1

2

You can push a new UIViewController programmatically

Refer to this answer: Push another View in UINavigationController?

See this answer for using Nibs: Navigation Controller Push View Controller

UIViewController *viewController = [[UIViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
Community
  • 1
  • 1
Tuan
  • 893
  • 1
  • 9
  • 24
  • thanks now please help me how i can set autolayout for multiple dynamic buttons .in same program code – user3228492 Oct 12 '14 at 07:41
  • 1
    I think you should accept this answer to your question if it applies and create another question concerning your autolayout problem. – Tuan Oct 12 '14 at 11:53