views:

133

answers:

0

So I have a tabbar with 5 tabs and each containing a tableview controller.

I was debugging a [self.tableView reloadData] no working when I added a self.title = @"Search by Last Name" on the viewDidLoad of the table view. Funny enough, I get that title in the tabbar item for that view.

can anyone tell me why that is??

the inital problem was the tableView loads the plist data just fine. but I will need to retrieve the data from a webservice (got that working already) but when I send the reloadData message the tableview seems to ignore it. However, when I move the tableView up and down the data appears... ???? WTF??

can you please help me out as well??

 // //  RootViewController.h

 @interface RootViewController : UIViewController { 
    IBOutlet UITabBarController *tabBarController;
 }

@property (nonatomic, retain) UITabBarController *tabBarController;

@end


//
//  RootViewController.m
//

-#import "RootViewController.h"

@implementation RootViewController
@synthesize tabBarController;

-(void)viewDidLoad {

    [super viewDidLoad];
    self.view = tabBarController.view;
}


//
//  SearchView.h
//

-#import <-UIKit/UIKit.h->

@interface SearchView : UIViewController <-UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate-> {

// table view

NSMutableArray *listData;

NSMutableDictionary *names;

NSMutableArray *keys;


// search bar 

IBOutlet UISearchBar * searchBar;

IBOutlet UITableView * tableView; 

BOOL isSearchOn;

BOOL canSelectRow;

}


// TableView 
@property (nonatomic, retain) NSMutableArray *listData;
@property (nonatomic, retain) NSMutableDictionary *names;
@property (nonatomic, retain) NSArray *keys;
@property (nonatomic, retain) UITableView * tableView;


// SearchBar
@property (nonatomic, retain) UISearchBar * searchBar;

-(void) doneSearching: (id)sender;
-(void) searchForFullNames;


//
//  SearchView.m

-#import "SearchView.h"


@implementation SearchView

@synthesize listData, names, keys, tableView;

@synthesize searchBar;


-(void)viewDidLoad {

self.title = @"Search by Last Name";

[self loadDataFromWebserice];

isSearchOn = NO;

canSelectRow = NO;

[self.tableView reloadData];

self.tableView.scrollEnabled = NO;

 [super viewDidLoad];

}


-(void) viewWillAppear:(BOOL)animated{

NSString *path = [[NSBundle mainBundle] pathForResource:@"search" ofType:@"plist"];

NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];

self.names = dict;

[dict release];

NSArray *array = [[names allKeys] sortedArrayUsingSelector:@selector(compare:)];

// NSArray *array = [names allKeys];

self.keys = array;


isSearchOn = NO;

canSelectRow = NO;

[super viewWillAppear:animated];

[self.tableView reloadData];

}