如何在ios中动态地将一个屏幕移动到另一个屏幕?

时间:2014-10-11 11:31:05

标签: ios objective-c xcode

我在项目中动态创建了5个按钮 现在,当我点击一个按钮时,我希望每个动态按钮的代码移动到下一个屏幕 如果您的示例示例与我的要求相同,请在此处发布。

我知道拖放控制很容易连接下一个表单,但我想动态地这样做 我到目前为止的代码:

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

1 个答案:

答案 0 :(得分:2)

您可以通过编程方式推送新的UIViewController

  

请参阅此答案:Push another View in UINavigationController?

     

请参阅此答案以使用Nibs:Navigation Controller Push View Controller

UIViewController *viewController = [[UIViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
相关问题