【问题标题】:Cannot get Twitter-OAuth-iPhone to work无法让 Twitter-OAuth-iPhone 工作
【发布时间】:2010-12-19 00:54:15
【问题描述】:

演示按预期工作,没有问题。但现在我正试图将它整合到我的项目中。我不使用 xib-s,只使用代码:

OAuthTwitterDemoViewController *vc = [[OAuthTwitterDemoViewController alloc] init]; [[UIApplication sharedApplication].keyWindow addSubview:vc.view]; [vc 发布];

它编译并运行没有错误,但实际的 OAuthTwitterDemoViewController 永远不可见。我还使用 [self.view addSubview:vc.view]

从自定义 viewController 尝试过

秘诀是什么??


更新:

好的,这就是我对 NavigationController 所做的:

    TwitterAuthViewController *vc = [[TwitterAuthViewController alloc] init];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
    [vc release];

    [self presentModalViewController:navigationController animated:YES];
    [navigationController release];

【问题讨论】:

  • 您是否尝试过将视图控制器推送到导航控制器?您的其他视图是否正确显示?
  • 这太快了,本!是的,UINavigationController 帮了很多忙——我可以看到 TwitterAuthViewController 的视图。但现在我得到 EXC_BAD_ACCESS ... 将尝试调查这个问题。有什么想法为什么它可以从 UINavigationController 工作而不是像我以前那样工作?..
  • 顺便说一句,我更新了上面的代码

标签: objective-c cocoa-touch twitter oauth


【解决方案1】:

好的,问题似乎是我从 ModalViewController->NavigationController 调用了[self presentModalViewController: controller animated: YES]。这就是 Cocoa touch 或 Twitter-OAuth-iPhone(我真的不知道到底是哪一个)有问题的地方。但这正是我需要的。

正如 Ben 已经说过的,解决方案是像 [self.navigationController pushViewController:controller animated: YES]; 这样简单地推送 SA_OAuthTwitterController。

唯一剩下的问题是 SA_OAuthTwitterController 在内部创建了自己的 NavigationController 栏,所以现在我有 2 个导航栏可见。

【讨论】:

  • SA_OAuthTwitterController 应该能够以 Modal 形式使用;要摆脱重复的导航栏,只需向其中一个导航控制器发送 -setNavigationBarHidden: 消息。
猜你喜欢
  • 2011-12-26
  • 2013-09-10
  • 2019-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-26
相关资源
最近更新 更多