gpt4 book ai didi

ios - 如何将登录添加到我的 iOS PDF 阅读器应用程序?

转载 作者:行者123 更新时间:2023-11-29 00:53:35 24 4
gpt4 key购买 nike

所以我正在尝试向我现有的应用程序添加登录信息。我的应用程序有两个 Storyboard,一个用于 iPhone,另一个用于 iPad。我添加了一个设置为 rootViewController 的登录 View ,但我似乎无法正确加载我的 UITabBarController。通常应该加载 PDF。我将登录名添加到 UITabBarController,但没有加载任何内容,它只是一个空的 Storyboard 。我没有正确加载它(标签栏和文档)或其他东西。我是菜鸟,所有帮助都表示赞赏。

应用委托(delegate)文件:

@interface AppDelegate () <UITabBarControllerDelegate>
@property (nonatomic, strong) PDFDocumentStore *documentStore;
@property (nonatomic, strong) DocumentListViewController *documentsViewController;
@property (nonatomic, strong) DocumentListViewController *recentViewController;
@property (nonatomic, assign) BOOL launchingWithURL;
@property (nonatomic, assign) BOOL addSkipBackupAttributeToItemAtURL;

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

[self migrateIfNeeded];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"Login"];
[[UIApplication sharedApplication].keyWindow setRootViewController:rootViewController];

self.documentStore = PDFDocumentStore.new;
[self.documentStore.rootFolder load];


UITabBarController *tabBar = (UITabBarController *)[[self window] rootViewController];
tabBar.delegate = self;

self.documentsViewController = (DocumentListViewController *)[tabBar.viewControllers[0] topViewController];
FolderDocumentListViewModel *folderModel =
[[FolderDocumentListViewModel alloc] initWithFolder:self.documentStore.rootFolder];
self.documentsViewController.viewModel = folderModel;
[self.documentsViewController view];

self.recentViewController = (DocumentListViewController *)[tabBar.viewControllers[1] topViewController];
RecentDocumentListViewModel *recentModel =
[[RecentDocumentListViewModel alloc] initWithDocumentList:self.documentStore.documentList];
self.recentViewController.viewModel = recentModel;

NSString *pdf = @"2016 Product Handbook";
NSString *toPath = [[[NSFileManager grt_documentsPath]
stringByAppendingPathComponent:pdf]
stringByAppendingPathExtension:@"pdf"];
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:toPath]];
NSURL *URL = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if (URL) {
self.launchingWithURL = YES;
}

return YES;
}

最佳答案

在“AppDelegate.h”文件中创建一个 UITabBarController

@property (strong, nonatomic) UITabBarController *tabBarController;
-(void)userDidLoginSuccessfully;

然后在AppDelegate.h文件中声明一个公共(public)函数。 (在这种情况下,可以说 userDidLoginSuccessively 是我的函数)。在您的 AppDelegate.m 文件中编写此函数。

-(void)userDidLoginSuccessfully{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
self.tabBarController = [[UITabBarController alloc]init]
self.tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"MyTabBarController"];
[self.window setRootViewController:self.TabBarController];
}

然后在 LoginViewController 中检查 if-else block 中登录是否成功,只需编写这些行。

AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate userDidLoginSuccessfully];

关于ios - 如何将登录添加到我的 iOS PDF 阅读器应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37848114/

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