iphone - Three20简单导航

标签 iphone three20

我开始使用Three20库并使用以下代码创建了 UIButton:

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add New" 
                                                                           style:UIBarButtonItemStyleBordered
                                                                          target:@"tt://samples/new"
                                                                          action:nil] autorelease];

当用户触摸按钮时,我想将 NewSampleViewController 的实例推送到导航上。我在应用程序委托(delegate)的 -didFinishLaunchingWithOptions 方法中添加了以下内容:

[map from:@"tt://samples/new" toViewController:[NewSampleViewController class]];

就目前情况而言,当触摸按钮时,什么也没有发生。设备上没有任何反应,我在控制台中没有看到任何日志记录。

我在这里做错了什么或错过了什么?

谢谢!

最佳答案

除非有一些我还没有发现的神奇东西,否则我认为您没有正确连接按钮委托(delegate)。看起来您已经告诉按钮字符串 @"tt://samples/new"是接收新闻事件的对象,并且您希望它不发送消息(不调用任何方法/nil)。

在 View Controller 中使用按钮创建一个方法,如下所示:

- (void)addButtonPressed:(id)sender{
  TTURLAction *urlAction = [TTURLAction actionWithURLPath:@"tt://samples/new"];
  [[TTNavigator navigator] openURLAction:urlAction];
}

然后将按钮 init 替换为:

    self.navigationItem.rightBarButtonItem = 
          [[[UIBarButtonItem alloc] initWithTitle:@"Add New" 
                                            style:UIBarButtonItemStyleBordered
                                           target:self
                                           action:@selector(addButtonPressed:)]
           autorelease];

这将调用 TTNavigator 单例实例来打开使用提供的字符串路径创建的操作。该按钮需要由按钮委托(delegate)来处理,而 self(您的 View Controller )非常适合于此。然后,处理程序方法会使用路径进行 Three2 导航。如果您在 appDelegate 中正确连接了所有内容,则 Three20 将创建并推送您映射的 View Controller 。 希望有帮助。

关于iphone - Three20简单导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5106548/

相关文章:

ios - iOS 5和Three20 SDK

objective-c - 在 TabBarController 中旋转 Three20 Photo ViewController

iphone - 从另一个选项卡重新加载 UITableView

iphone - 帮助理解 UIVIewController 和 UIView 子类之间的交互

iphone - 来电唤醒iOS后台应用程序?

iphone - 弹出拇指 View Controller 后, View Controller 正在我的导航栏下绘制

iphone - Three20 和 Apple 应用商店提交

ios - 如何将 sqlite 数据库值添加到数组中以及如何将这些值添加到 TableView 中?

ios - 展开两个 segue

iphone - Three20 数据源项和 TableViewController 之间的通信