user3228492
user3228492

Reputation: 21

how can i move one screen to another dynamically in ios?

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

Upvotes: 0

Views: 2992

Answers (1)

Tuan
Tuan

Reputation: 952

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];

Upvotes: 2

Related Questions