320

来源:互联网 发布:在线图片制作软件 编辑:程序博客网 时间:2024/04/28 04:47
Thanks!  I've tried doing this, but am having some issues. When I  switch the datasource and call reloadData, I see the follow trace in  the debugger: #0 0x93fa3688 in objc_msgSend #1 0x30bed381 in -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] #2 0x30bed6dc in -[UITableViewRowData invalidateAllSections] #3 0x30a9ca9f in -[UITableView(_UITableViewPrivate) _updateRowData] #4 0x30aa1885 in -[UITableView noteNumberOfRowsChanged] #5 0x30aa65eb in -[UITableView reloadData] #6 0x000127ee in -[ProfileViewController tabBar:tabSelected:] at ProfileViewController.m:143 I'm not sure if I'm doing something wrong or not?  Do I need to invalidate the datasource first or is there a different way to change it? Here is the sample code that I'm using. #import <Three20/Three20.h> @interface ProfileViewController: TTTableViewController <TTTabBarDelegate> {         TTTabBar* _tabBar; } @end #import "ProfileViewController.h" static NSString* kLoremIpsum = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud\ exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; @implementation ProfileViewController - (id)init {         NSLog(@"ProfileViewController.init()");         self = [super init];         if (self) {                 // this title will appear in the navigation bar                 self.title = NSLocalizedString(@"ButtonsTitle", @"");         }         return self; } - (void)dealloc {         [super dealloc]; } - (void)loadView {         NSLog(@"ProfileViewController.loadView()");         // Create View         self.view = [[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];         self.view.backgroundColor = RGBCOLOR(240, 242, 245);         // Create tabbar         _tabBar = [[TTTabBar alloc] initWithFrame:CGRectMake(0, 100, 320, 41)                                                                                 style:TTTabBarStyleLight];         _tabBar.delegate = self;         _tabBar.contentMode = UIViewContentModeScaleToFill;         _tabBar.tabItems = [NSArray arrayWithObjects:                                                 [[[TTTabItem alloc] initWithTitle:@"Red"] autorelease],                                                 [[[TTTabItem alloc] initWithTitle:@"Green"] autorelease],                                                 [[[TTTabItem alloc] initWithTitle:@"Blue"] autorelease],                                                 nil];         // create and configure the table view         self.tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]                                                                                                   style:UITableViewStylePlain];         self.tableView.autoresizesSubviews = YES;         self.tableView.tableHeaderView = _tabBar;         self.tableView.backgroundColor = RGBCOLOR(240, 242, 245);         [self.view addSubview:self.tableView]; } ///////////////////////////////////////////////////////////////////////////­//////////////////////// // TTTableViewController - (id<TTTableViewDataSource>)createDataSource {         // This demonstrates how to create a table with standard table "fields".  Many of these         // fields with URLs that will be visited when the row is selected         return [TTSectionedDataSource dataSourceWithObjects:                         @"Buttons",                         [[[TTTableField alloc] initWithText:@"TTTableField"                                                                                         url:@"tt://tableFieldTest"] autorelease],                         [[[TTTableField alloc] initWithText:@"TTTableField (external link)"                                                                                         url:@"http://foo.com"] autorelease],                         [[[TTLinkTableField alloc] initWithText:@"TTLinkTableField"                                                                                                 url:@"tt://tableFieldTest"] autorelease],                         [[[TTIconTableField alloc] initWithText:@"TTIconTableField" url:@"tt://tableFieldTest"                                                                                           image:@"bundle://tableIcon.png" ] autorelease],                         [[[TTImageTableField alloc] initWithText:@"TTImageTableField" url:@"tt://tableFieldTest"                                                                                            image:@"bundle://person.jpg"] autorelease],                         [[[TTButtonTableField alloc] initWithText:@"TTButtonTableField"] autorelease],                         [[[TTTitledTableField alloc] initWithTitle:@"title"                                                                                                   text:@"TTTitledTableField" url:@"tt://tableFieldTest"] autorelease],                         [[[TTMoreButtonTableField alloc] initWithText:@"TTMoreButtonTableField"                                                                                                  subtitle:@"Showing 1 of 100"] autorelease],                         @"Static Text",                         [[[TTTableField alloc] initWithText:@"TTTableField"] autorelease],                         [[[TTTitledTableField alloc] initWithTitle:@"title"                                                                                                   text:@"TTTitledTableField which wraps to several lines"] autorelease],                         [[[TTSubtextTableField alloc] initWithText:@"TTSubtextTableField"                                                                                            subtext:kLoremIpsum] autorelease],                         [[[TTTextTableField alloc] initWithText:kLoremIpsum] autorelease],                         [[[TTGrayTextTableField alloc] initWithText:kLoremIpsum] autorelease],                         [[[TTActivityTableField alloc] initWithText:@"TTActivityTableField"] autorelease],                         [[[TTSummaryTableField alloc] initWithText:@"TTSummaryTableField"] autorelease],                         @"Controls",                         [[[TTSwitchTableField alloc] initWithText:@"TTSwitchTableField"] autorelease],                         [[[TTTextFieldTableField alloc] initWithTitle:@"Title" text:@"TTTextFieldTableField"]                          autorelease],                         [[[TTTextViewTableField alloc] initWithText:@"TTTextViewTableField"] autorelease],                         nil]; } - (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {         NSLog(@"didSelectObject atIndexPath: %d", indexPath.row);                 //[_delegate searchTestController:self didSelectObject:object]; } ///////////////////////////////////////////////////////////////////////////­//////////////////////// // TTTabBarDelegate - (void)tabBar:(TTTabBar*)tabBar tabSelected:(NSInteger)selectedIndex {         NSLog(@"tabSelected: %d", selectedIndex);         self.dataSource =[TTSectionedDataSource dataSourceWithObjects:                                                  @"Buttons",                                                  [[[TTTableField alloc] initWithText:@"TTTableField"                                                                                                                  url:@"tt://tableFieldTest"] autorelease],                                                  [[[TTTableField alloc] initWithText:@"TTTableField (external link)"                                                                                                                  url:@"http://foo.com"] autorelease],                                                  [[[TTLinkTableField alloc] initWithText:@"TTLinkTableField"                                                                                                                          url:@"tt://tableFieldTest"] autorelease],                                                  [[[TTIconTableField alloc] initWithText:@"TTIconTableField" url:@"tt://tableFieldTest"                                                                                                                    image:@"bundle://tableIcon.png" ] autorelease],                                                  [[[TTImageTableField alloc] initWithText:@"TTImageTableField" url:@"tt://tableFieldTest"                                                                                                                         image:@"bundle://person.jpg"] autorelease],                                                 [[[TTButtonTableField alloc] initWithText:@"TTButtonTableField"] autorelease],                                                  [[[TTTitledTableField alloc] initWithTitle:@"title"                                                                                                                            text:@"TTTitledTableField" url:@"tt:// tableFieldTest"] autorelease],                                                  [[[TTMoreButtonTableField alloc] initWithText:@"TTMoreButtonTableField"                                                                                                                           subtitle:@"Showing 1 of 100"] autorelease],nil];         /*         [self setDataSource:[TTSectionedDataSource dataSourceWithObjects:                                                  @"Buttons",                                                  [[[TTTableField alloc] initWithText:@"TTTableField"                                                                                                                  url:@"tt://tableFieldTest"] autorelease],                                                  [[[TTTableField alloc] initWithText:@"TTTableField (external link)"                                                                                                                  url:@"http://foo.com"] autorelease],                                                  [[[TTLinkTableField alloc] initWithText:@"TTLinkTableField"                                                                                                                          url:@"tt://tableFieldTest"] autorelease],                                                  [[[TTIconTableField alloc] initWithText:@"TTIconTableField" url:@"tt://tableFieldTest"                                                                                                                    image:@"bundle://tableIcon.png" ] autorelease],                                                  [[[TTImageTableField alloc] initWithText:@"TTImageTableField" url:@"tt://tableFieldTest"                                                                                                                         image:@"bundle://person.jpg"] autorelease],                                                 [[[TTButtonTableField alloc] initWithText:@"TTButtonTableField"] autorelease],                                                  [[[TTTitledTableField alloc] initWithTitle:@"title"                                                                                                                            text:@"TTTitledTableField" url:@"tt:// tableFieldTest"] autorelease],                                                  [[[TTMoreButtonTableField alloc] initWithText:@"TTMoreButtonTableField"                                                                                                                           subtitle:@"Showing 1 of 100"] autorelease],nil]];         */         [self.tableView reloadData]; } @end 

原创粉丝点击