2011-10-19 10 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; 
    } 

ことcannt、私は[self.tableviewa reloadData]機能numberOfRowInSectionを有する方法リロードを呼び出すときどのようにすることができますか?この問題の原因は何ですか?なぜのUITableViewはviewWillAppearがコードは[self.tableviewa reloadData]であり、numberOfRowsInSectionを呼び出すときに、この方法でreloadData

firstTime viewWillAppearが呼び出されたため、[cachedProperties setTags:nil]がタグを設定し、tableViewがnullでないようにするために-(void) reload{ [self.tableViewa reloadData]; }または[thatClass.tableViewa reloadData]を呼び出します。 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; 
    } 

...

関連する問題