1. 首页要实现TTActionSheetControllerDelegate
@interface TSPublishViewController : TTTableViewController<TTActionSheetControllerDelegate> {CATETYPE _cateType; } @property(nonatomic,assign)CATETYPE cateType;@end
2. 在init中声明URLMAP规则
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {self.tableViewStyle = UITableViewStyleGrouped;[[TTNavigator navigator].URLMap from:@"tt://displayChoices"toViewController:self selector:@selector(displayChoices:)];}return self; }
3. 在DataSource中tableViewDidLoadModel添加url
[items addObject:[TTTableTextItem itemWithText:post.catname URL:@"tt://displayChoices"]];
4. 实现在方法
- (UIViewController*)displayChoices:(NSDictionary*)query{TTActionSheetController *controller = [[[TTActionSheetController alloc] initWithTitle:@"Choose" delegate:self] autorelease];[controller addDestructiveButtonWithTitle:@"Sigin In & Post" URL:@"tt://safechoice"];[controller addButtonWithTitle:@"Create & Post" URL:@"tt://photo-library"];[controller addCancelButtonWithTitle:@"Cancel" URL:nil];return controller; }- (BOOL)actionSheetController:(TTActionSheetController *)controller didDismissWithButtonIndex:(NSInteger)buttonIndex URL:(NSString *)URL {TTDPRINT(@"buttonIndex: %d URL: %@", buttonIndex, URL);if (URL && [URL caseInsensitiveCompare:@"tt://manual"] == NSOrderedSame) {return NO;}return (nil != URL); }