gpt4 book ai didi

ios - 在 IOS 中使用 Storyboard标识符实例化 ViewController

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:26:24 24 4
gpt4 key购买 nike

我在一个 iOS 应用程序中工作,该应用程序允许用户使用他的 Facebook 帐户登录。我们登录的用户我想推送填充了用户数据的配置文件 ViewController; 抱歉,准备时间这么长

问题是当我使用 instantiateViewControllerWithIdentifier 方法来启动配置文件 View Controller 时。它的导出组件都是零

这是我遇到问题的代码

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
profileViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CGProfileViewController"];
profileViewController.fbProfilePictureView.profileID=user.objectID;
profileViewController.nameLabel.text=user.name;
profileViewController.locationLabel.text=user.location.location.city;

// [self presentViewController:profileViewController animated:YES completion:nil]

enter image description here

我的代码有问题吗?我应该怎么办 ?提前致谢

最佳答案

这里的问题是您正在引用尚未创建的导出。我会尝试将用户模型添加为 View Controller 的属性(或为此使用某种中间 Controller ),在上面的函数中设置用户属性,然后在 viewDidAppear 中设置所有文本控件适本地使用用户模型。

如果您在 viewDidAppear 函数上执行此操作,您可以确定所有 View 都已实例化。毕竟,这也是更好的设计;为什么您的 LoginViewController 类需要了解 profileViewController 的内部结构?以这种方式封装逻辑将导致更少的问题。

希望这对您有所帮助。

关于ios - 在 IOS 中使用 Storyboard标识符实例化 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29280561/

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