I am starting to work with the Three20 library and created a UIButton using the following code:
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add New"
style:UIBarButtonItemStyleBordered
target:@"tt://samples/new"
action:nil] autorelease];
When the user touches the button, I would like to push an instance of NewSampleViewController onto the nav. I have added the following in my app delegate’s -didFinishLaunchingWithOptions method:
[map from:@"tt://samples/new" toViewController:[NewSampleViewController class]];
As it stands, when the button is touched, nothing happens at all. Nothing happens on the device and I don’t see any logging going on in the console.
What have I done wrong or missed here?
Thanks!
Unless there is something magical I haven’t discovered yet, I don’t think you’ve wired your button delegation correctly. It looks like you’ve told the button that the string @”tt://samples/new” is the object that receives the press event and you want it to send no message (call no method / nil).
Create a method in the view controller with the button, such as this:
Then replace your button init with this:
This will invoke the TTNavigator singleton instance to open the action created with the string path provided. The button needs to be handled by a button delegate and self, your view controller, is perfectly appropriate for that. The handler method then causes a three2 navigation using a path. If you’ve got things wired correctly in your appDelegate, three20 will create and push the view controller you mapped.
Hope that helps.