gpt4 book ai didi

ios - PresentViewController iOS 上的 PushView

转载 作者:行者123 更新时间:2023-12-01 19:05:55 24 4
gpt4 key购买 nike

我要 Push我在 PresentViewController 上的 View Controller

当我最初单击按钮时,我正在加载 PresentViewController ,这是我的代码。

- (IBAction)JoinClicked:(id)sender{

JoinWithViewController *detail_view_controller = [[JoinWithViewController alloc] initWithNibName:@"JoinWithViewController" bundle:nil];
[self.view.window.rootViewController presentViewController:detail_view_controller
animated:YES
completion:NULL];

}

这很好用,但是当我单击 PresentViewController 上的按钮时单击时我想推送我的 View ,但不推送。

请帮助,在此先感谢。

最佳答案

JoinWithViewController *detail_view_controller = [[JoinWithViewController alloc] initWithNibName:@"JoinWithViewController" bundle:nil];
[self.navigationController pushViewController:detail_view_controller animated:YES];

尝试像这样推送 viewController。如果您使用 TabBar,请在 中执行此操作应用委托(delegate) .如果您创建 TabBar 拖放意味着离开。以编程方式创建 TabBar,如下所示。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UITabBarController *tabController = [[UITabBarController alloc]init];

self.viewController = [[CalculatorViewController alloc] initWithNibName:@"CalculatorViewController" bundle:nil];
UITabBarItem *tab_item1 = [[UITabBarItem alloc]init];
//tab_item1.title = @"Calculator";
tab_item1.image = [UIImage imageNamed:@"Calculator.png"];
[self.viewController setTabBarItem:tab_item1];
UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:self.viewController];

ShowPhoneViewController *phone = [[ShowPhoneViewController alloc]init];
UITabBarItem *tab_item2 = [[UITabBarItem alloc]init];
tab_item2.title = @"Latest Mobiles";
tab_item2.image = [UIImage imageNamed:@"Mobile.png"];
[phone setTabBarItem:tab_item2];
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:phone];

CurrencyConvertorViewController *currency = [[CurrencyConvertorViewController alloc]init];
UITabBarItem *tab_item3 = [[UITabBarItem alloc]init];
tab_item3.title = @"Units Convertor";
tab_item3.image = [UIImage imageNamed:@"Dollar.png"];
[currency setTabBarItem:tab_item3];
UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:currency];

SettingsPageViewController *setting = [[SettingsPageViewController alloc]init];
UITabBarItem *tab_item4 = [[UITabBarItem alloc]init];
tab_item4.title = @"Settings";
tab_item4.image = [UIImage imageNamed:@"Settings.png"];
[setting setTabBarItem:tab_item4];
UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:setting];


tabController.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nav3, nav4, nil];
self.window.rootViewController = tabController;

[self.window makeKeyAndVisible];
return YES;
}

我希望你现在得到

关于ios - PresentViewController iOS 上的 PushView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19675528/

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