cho*_*ise 9 iphone cocoa-touch objective-c three20
以下情况:
在TTTableViewController中我添加了一些带URL的单元格.例如,他们正在开设一个班级@"tt://photos".这很好用.
第一件事是,我在TT示例中看到了一些网址,比如@"tt/photos/1".是否有可能在我的照片类中获取此"1"并说,例如,好的,请打开图片一,这是否只是在TTNavigatior中声明的另一个URL来打开特定的类?
另一件事是:是否可以将对象转发给链接类?单击一个单元格打开@"tt:// photos"(我的TTNavigator中的链接类)
使用普通的tableviews我可以覆盖我的init方法并使用我的initialize方法发送一个对象,这也可以点击我的TTItems吗?
谢谢!
cho*_*ise 21
对于那些需要它的人来说,我自己想出来了:
首先(在导航器地图中传递"subURLs")
可以使用@"tt:// photos/firstphoto"导航到URL,您可以像这样获取"firstphoto":
//Prepare your Navigator Map like this
[map from:@"tt://photos/(initWithNumber:)" toViewController:[PhotoVC class]];
Run Code Online (Sandbox Code Playgroud)
在您的PhotoVC中,您可以访问此号码:
-(void) initWithNumber: (NSString*)number {
NSLog(@"%@",number);
}
Run Code Online (Sandbox Code Playgroud)
使用此URL调用View Controller将显示:
PhotoVC* controller = [[PhotoVC alloc] initWithNumber:@"1"];
[navigationController pushViewController:controller animated:YES];
[controller release];
Run Code Online (Sandbox Code Playgroud)
第二个(在TTTableViewController中传递对象)
它有点棘手,但你没有Subclass任何东西.
首先,在TableItem中找到URL
[TTTableLink itemWithText:@"TTTableLink" URL:nil]
Run Code Online (Sandbox Code Playgroud)
在你的TTTableViewController中写下这个方法
- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:@"tt://photos"] autorelease];
urlAction.query = [NSDictionary dictionaryWithObject:@"firstphoto" forKey:@"photo"];
urlAction.animated = YES;
[[TTNavigator navigator] openURLAction:urlAction];
}
Run Code Online (Sandbox Code Playgroud)
现在在你的PhotoVC中你需要这样的东西
- (id)initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
if (self = [super init]) {
NSLog(@"%@",query);
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
你完成了;)
| 归档时间: |
|
| 查看次数: |
6910 次 |
| 最近记录: |