Reputation: 21
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
Reputation: 952
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