gpt4 book ai didi

ios - 查看从不加载

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

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {

MainView *Main=[[MainView alloc]initWithNibName:@"MainView" bundle:nil];
// This module to collect metrics for Notification received, Notification displayed
UINavigationController *NavBar=[[UINavigationController alloc] initWithRootViewController:Main];

// react to shortcut item selections
NSLog(@"A shortcut item was pressed. It was %@.", shortcutItem.localizedTitle);
if([(NSString *)shortcutItem.localizedTitle isEqualToString:@"Store"])
{
PurchaseView *purchaseViewController = [[PurchaseView alloc] initWithNibName:@"PurchaseView" bundle:nil];
[NavBar pushViewController:purchaseViewController animated:YES];
}
}

我进入 if([(NSString *)shortcutItem.localizedTitle isEqualToString:@"Store"]) 循环,我看到代码正在执行。但 PurchaseView.xib 永远不会加载。我有类似的推送通知代码,它在我推送要加载的 View 时有效。

如有任何帮助,我们将不胜感激。

最佳答案

这里的问题是糟糕的 View 层次结构。您将 XIB 文件的 View Controller 添加到一个全新的 UINavigationController,它在 View 层次结构中的任何位置都不存在。我相信你想做这样的事情:

UINavigationController *navBar = (UINavigationController *) self.tabBarController.selectedViewController;
[navBar pushViewController:purchaseViewController animated:YES];

同样,以上是一个假设的例子。您需要在 View 层次结构中找到正确的 UINavigationController

关于ios - 查看从不加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32869989/

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