0

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

主视图控制器

- (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)];
 }

表视图数据源方法

- (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没有被调用。

4

0 回答 0