开发者

TTTableView within a TTViewController

I am using Three20 to add some table views (TTTableView). I have a TTViewController which adds a TTTableView as a 开发者_C百科subview using:

    _signupTableView = [[TTTableView alloc] initWithFrame:CGRectMake(0, kScrollViewHeight + kSignupLabelHeight, 320, kTableViewHeight) style:UITableViewStyleGrouped];
        [_signupTableView setBackgroundColor:[UIColor clearColor]];

        _signupTableView.delegate = self;
        _signupTableView.dataSource = [TTSectionedDataSource dataSourceWithObjects:
                                                   @"",
                                                   [TTTableTextItem itemWithText:@"Sign Up" URL:@"tt://signupController"],
                                                   nil];
[self.view addSubview:_signupTableView];

And all works ok, EXCEPT when the cell is tapped. The cell turns blue, and remains that way. The navigation is never pushed to tt://signupController.

Can anyone think of a reason that this is not working??? I found a similar SO question describing the same symptoms, but their issue was with the drag-to-refresh controller, which I am not using.

Any help would be great, I am at a loss here.

Cheers, Brett


Without seeing any other code it sounds like that you haven't set up the mappings to the different ViewControllers in your App Delegate. Try adding to your App Delegate:

TTURLMap* map = navigator.URLMap;
[map from:@"tt://signupController" toViewController: NSClassFromString(@"SignupController")];

Hope this might help you out.


i think this is what you want-

-(void)didSelectObject:(id)object atIndexPath:(NSIndexPath *)indexPath {

    NSLog(@"%d", indexPath.row);
    int i = indexPath.row;

    TTNavigator *navi = [TTNavigator navigator];
    navi.persistenceMode = TTNavigatorPersistenceModeNone;
    TTURLAction *action =  [[[TTURLAction actionWithURLPath:@"tt://signupController"] applyQuery:[NSDictionary dictionaryWithObject:arr forKey:@"stories"]] applyAnimated:YES];
    [navi openURLAction:action];    
}

but could you explain me how you made TTTableView inside TTViewController? i also tried your code above but it crashes with several warnings related to TTModel. Here is the code i made-

CODE OF .H FILE-

@interface Social1 : TTViewController <TTTableViewDataSource, TTTableViewDelegate, TTModelDelegate> {

    TTTableView *_tableview;
}
@property(nonatomic, retain)TTTableView *_tableview;
@end

CODE OF .M FILE INSIDE viewDidLoad

    self._tableview = [[TTTableView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, 330) style:UITableViewStyleGrouped];
    self._tableview.delegate = self;
    self._tableview.dataSource =
    [TTListDataSource dataSourceWithObjects:
     [TTTableMessageItem itemWithTitle:@"Facebook" 
                               caption:nil
                                  text:kLoremIpsum timestamp:nil
                              imageURL:local_fb URL:@"tt://socialfb"],
     [TTTableMessageItem itemWithTitle:@"Twitter" caption:nil
                                  text:kLoremIpsum timestamp:nil
                              imageURL:local_tw URL:@"http://www.twitter.com/eset"],
     [TTTableMessageItem itemWithTitle:@"YouTube" caption:nil
                                  text:kLoremIpsum timestamp:nil
                              imageURL:local_yt URL:@"tt://videos"],
     [TTTableMessageItem itemWithTitle:@"LinkedIn" caption:nil
                                  text:kLoremIpsum timestamp:nil
                              imageURL:local_li URL:@"http://m.LinkedIn.com/"],
     nil];
    [self.view addSubview:self._tableview];
}

Does the code require any other delegate methodes? Please reply.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜