1

I have a popover view that I added a PFQueryTableViewController too, as a childviewController. I have a button on the popover that, when pressed, should reload the tableview in the PFQueryTableViewController.

Here is the code in the buttonPressed method that should do this:

NotificationsTableViewController *note = (NotificationsTableViewController *)self.childViewControllers[0];
[note loadObjects];
[note.tableView reloadData];

The table is not reloaded, though, and the only way I can get it to reload is by instantiating a whole new controller and adding it to the popover, which is not something I want to end up doing.

Here is some more code:

//NotificationsPopoverController

@class NotificationsTableViewController;

@protocol PopDelegate <NSObject>

-(void) changedQue;
@end

@interface NotificationsPopoverController : PDPopoverController

@property (nonatomic, assign) id<PopDelegate>  myDelegate;

@property NotificationsTableViewController *noti;

When my button is pressed I call [self.myDelegate changedQue];

//NotificationsTableViewController.h

@interface NotificationsTableViewController : PFQueryTableViewController <PopDelegate>

//NotificationsTableViewController.m

-(void)changedQue
{
    NSLog(@"Did it work?");

    [self.tableView reloadData];
    [self loadObjects];

}

The log statement is not printed for some reason, not sure why...

Jacob
  • 2,338
  • 2
  • 22
  • 39
  • Can you please add more code? may be paste the code for the entire view controller. – Ricky Jul 04 '14 at 01:42
  • Which view controller? – Jacob Jul 04 '14 at 01:46
  • It's ok. You can not reload the tableview in NotificationsTableViewController by creating another instance and call reloadData. It does not work this way in iOS. You will have to use delegate to reload the tableView in another viewController. – Ricky Jul 04 '14 at 01:48
  • I have tried that but the delegate method does not get called in the child view controller for some reason. I will edit my post with this code... – Jacob Jul 04 '14 at 01:51
  • Add your delegate method code on both the view controllers and I will see how I can help you further. – Ricky Jul 04 '14 at 01:52
  • I added more code to the question^^ – Jacob Jul 04 '14 at 01:55
  • I haven't understand the flow completely yet. I think somewhere you will have to add **self.note.myDelegate = self;**. Hm... I think your have implemented delegate wrongly. Can you paste more complete code on both the view controller. – Ricky Jul 04 '14 at 01:59
  • I don't think that call is possible... – Jacob Jul 04 '14 at 02:01
  • May be this will help: http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c – Ricky Jul 04 '14 at 02:03
  • I think I figured it out. The statement logged when I added this **self.myDelegate = self.noti;** right after I added noti as a child view. – Jacob Jul 04 '14 at 02:04
  • Good to hear that. ;) – Ricky Jul 04 '14 at 03:05

1 Answers1

0

I haven't understand the flow completely yet. I think somewhere you will have to add self.note.myDelegate = self;. Hm... I think your have implemented delegate wrongly. Can you paste more complete code on both the view controller.

As per Jacob, add self.myDelegate = self.noti; right after the child view noti solves the problem.

Ricky
  • 10,485
  • 6
  • 36
  • 49