Iphone Three20简单导航
我开始使用该库,并使用以下代码创建了一个UIButton:Iphone Three20简单导航,iphone,three20,Iphone,Three20,我开始使用该库,并使用以下代码创建了一个UIButton: self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add New" style:UIBarButtonItemStyleBordered
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add New"
style:UIBarButtonItemStyleBordered
target:@"tt://samples/new"
action:nil] autorelease];
当用户点击按钮时,我想将NewSampleViewController的一个实例推到nav上。我已在我的应用程序代理的-didFinishLaunchingWithOptions方法中添加了以下内容:
就目前情况而言,当按下按钮时,什么也不会发生。设备上没有发生任何事情,我也看不到控制台中正在进行任何日志记录
我做错了什么或错过了什么
谢谢 这可能行得通,我用它将视图推送到导航控制器上。对导航栏按钮进行操作,然后执行以下操作:
-(IBAction)navigationRightBarButton:(id)sender{
[[TTNavigator navigator] openURLAction:
[TTURLAction actionWithURLPath:@"tt://samples/new"]]; // goes tot he ttLauncher class
}
这将把视图推到正确的url路径,希望这会有所帮助。除非我还没有发现什么神奇的东西,否则我认为您的按钮授权没有正确连接。看起来您已经告诉按钮,字符串@tt://samples/new是接收press事件的对象,您希望它不发送消息call no method/nil 使用按钮在视图控制器中创建方法,例如:
- (void)addButtonPressed:(id)sender{
TTURLAction *urlAction = [TTURLAction actionWithURLPath:@"tt://samples/new"];
[[TTNavigator navigator] openURLAction:urlAction];
}
然后将按钮初始化替换为以下内容:
self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Add New"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(addButtonPressed:)]
autorelease];
这将调用TTNavigator singleton实例来打开使用提供的字符串路径创建的操作。该按钮需要由按钮代理处理,而您的视图控制器self非常适合处理该按钮。然后,handler方法使用路径进行three2导航。如果在appDelegate中正确连接了内容,three20将创建并推送映射的视图控制器。
希望这会有所帮助。Levous的解决方案很有效,但您可以使用神奇的Three20 openURLFromButton:selector来简化,而不是实现自己的解决方案。试试这个:
self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Add New"
style:UIBarButtonItemStyleBordered
target:@"tt://samples/new"
action:@selector(openURLFromButton:)] autorelease];
如果您想了解这项工作的原因,请执行以下操作:
Three20/src/Three20UI/source/uinstringaditions.m
简而言之,Three20在NSString上添加了openUrlFromButton方法,该方法调用TTNavigator openURLAction
注:
此解决方案不起作用,因为发送方必须是UIView类型,而UIBarButton不是。但它在v1.02之前就已经运行了。现在,您需要使用OpenURL自己实现选择器。Jeff Three20 big boss在第463号请求中对此发表了评论:
self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Add New"
style:UIBarButtonItemStyleBordered
target:@"tt://samples/new"
action:@selector(openURLFromButton:)] autorelease];