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

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

最佳答案

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

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

关于ios - 如何在 ios 中动态地将一个屏幕移动到另一个屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26314156/

相关文章:

ios - 为什么我的容器中 View 中的组件不可用?

ios - 如何使用警报 View 刷新 uitableivew?

ios - 什么是 WebKitErrorDomain 错误代码 204?

ios - GCDAsyncSocket-如何使其连接?

xcode - 转换为自动引用计数 (ARC) : 'Use of undeclared identifier' errors

ios - XCode-iOS : Can't resolve conflict between CocoaLibSpotify and Parse framework

ios - 界面生成器中的约束 "width equals height",对于同一 View : how to create such a constraint?

ios - 删除按钮 ios swift 的所有动画

objective-c - 如何更正 "Undefined symbols for architecture i386: "_main"链接问题?

iOS用户数据存储困境