gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:56:41 24 4
gpt4 key购买 nike

我正在我的项目中动态创建 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com