2011-10-19 78 views
0
-(void) reload{ 
     [self.tableViewa reloadData]; 
    } 

    -(void) viewWillAppear:(BOOL)animated{ 
     [self.tableViewa reloadData]; 
     [cachedProperties setTags:nil]; 


     self.tabBarController.navigationItem.rightBarButtonItem =nil; 
     self.tabBarController.navigationItem.leftBarButtonItem =nil; 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
     return [[cachedProperties getTags] count]; 
    } 

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     static NSString *CheckMarkCellIdentifier = @"CheckMarkCellIdentifier"; 
     UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CheckMarkCellIdentifier] autorelease]; 

     NSUInteger row = [indexPath row]; 

     if([[[cachedProperties getTags] objectAtIndex:row] isNotEmpty]){ 
      cell.textLabel.text = [[cachedProperties getTags]objectAtIndex:row]; 
      cell.accessoryType= UITableViewCellAccessoryDetailDisclosureButton; 
     } 
     return cell; 
    } 

用这种方法,当viewWillAppear中有一个代码[self.tableviewa reloadData]并呼吁numberOfRowsInSection,但是当我调用方法重载有[self.tableviewa reloadData]功能numberOfRowInSection将不会被称为..它怎么会是?这个问题的任何原因?为什么UITableView的cannt是reloadData

因为在firstTime viewWillAppear调用时,[cachedProperties setTags:nil]会设置标签,并且会调用-(void) reload{ [self.tableViewa reloadData]; }或[thatClass.tableViewa reloadData]我需要使tableView不为null。为什么tableView不reloadData?

+1

怎么样'numberOfSectionsInTableView:'方法?你是否检查过它返回的值不是“0”? –

回答

0

试试这个:

-(void) reload{ 
     [self.tableViewa reloadData]; 
     [cachedProperties setTags:nil]; 
    } 

    -(void) viewWillAppear:(BOOL)animated{ 
     [self reload]; 

     self.tabBarController.navigationItem.rightBarButtonItem =nil; 
     self.tabBarController.navigationItem.leftBarButtonItem =nil; 
    } 

...