UITableView数据源方法只被调用一次

时间:2013-05-13 07:22:29

标签: ios objective-c uitableview viewdidappear

从详细视图控制器返回后,我的cellForRowAtIndexPath没有得到更新。

HomeViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title  =@"Welcome";

[eventsTable registerNib:[UINib nibWithNibName:@"EventCell" bundle:nil] forCellReuseIdentifier:@"EventCell"];

//filtering process from current date
[self fetchUsersForType:1];
[eventsTable reloadData];

// Configure the bar button Items..
UIBarButtonItem *filterButton = [[UIBarButtonItem alloc]initWithTitle:@"Filter" style:UIBarButtonItemStylePlain target:self action:@selector(filterTapped:)];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addTapped:)];
self.navigationItem.leftBarButtonItem = filterButton;
self.navigationItem.rightBarButtonItem = addButton;

refreshControl= [[UIRefreshControl alloc]init];
[eventsTable addSubview:refreshControl];

//testing

    [refreshControl addTarget:self action:@selector(reloadTable) forControlEvents:UIControlEventValueChanged];  //performing async operation here





[bottomView setFrame:CGRectMake(0, self.view.frame.size.height-69, 320, 69)];
 }

tableview数据源方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {

return  [self.eventsArray count];//1;//[sectionInfo numberOfObjects];
 }

 // Customize the appearance of table view cells.
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath   *)indexPath
 {

 static NSString *CellIdentifier = @"EventCell";

//testing


EventCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PersonEvent *currentEvent = [self.eventsArray objectAtIndex:indexPath.row];
[cell configureForEvent:currentEvent];
   return cell;

 }

ViewDidAppear

  -(void)viewDidAppear:(BOOL)animated
 {
[super viewDidAppear:animated];



[[NSNotificationCenter defaultCenter]removeObserver:self];
  [self reloadTable];
 }

- (void)reloadTable
{
NSLog(@"Reloading table view for the new contacts .");
[self fetchUsersForType:currentFilterIndex];
[eventsTable reloadData];
[refreshControl endRefreshing];
  NSLog(@"Observer finished.");
}

由于我使用了刷新控件,因此在刷新两次后会更新,问题是什么?

我也设置了断点,但cellForRowAtIndexPath仅在第一次被调用,但是当我选择一个特定的行并输入一个详细视图控制器并返回时,我的cellForRowAtIndexPath不会被调用。 / p>

0 个答案:

没有答案