0
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    // Handle the notificaton when the app is running

    NSLog(@"Recieved Notification %@",notif);

    NSLog(@"local notifications count = %d", [[[UIApplication sharedApplication] scheduledLocalNotifications] count]);
}

これはアプリデリゲートからのメソッドであり、通知が到着したときにテーブルビューをリロードする必要があります。

「[TableViewController.tableViewreloadData];」と書くとXcodeは受け入れないので、どうすればreloadDataを実装できますか?

4

4 に答える 4

4
//Just do one thing, as you got the notification , post on more notification as follows in the method ....

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {

[[NSNotificationCenter defaultCenter] postNotificationName:@"RELOAD_DATA"object:nil];
}

//the add observer in viewDidLoad of that view controller where your table is added..

 [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(receiveTableNotification:) 
    name:@"RELOAD_DATA"
    object:nil];

//and make a method in the same class 

- (void)receiveTableNotification:(NSNotification *)pNotification{
    [your_table_view reloadData];
}

//now remove obser in dealloc in your view controller class where you add observer .. 

- (void) dealloc
{

    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
 }
于 2012-06-26T07:59:10.150 に答える
0

TableViewController.tableView使用する代わりに[self.viewController.tableView reloadData];

現在のViewControllerがtableViewでない場合は、を使用NSNotificationCenterしてリロード通知を投稿することを検討してください

于 2012-06-26T07:27:35.117 に答える
0

NSNotificationCenter postNotification:tableViewControllerを持つクラスでキャッチできるreloadTable通知を投稿するメカニズムをobserver使用して、テーブルビューをreloadData起動します

于 2012-06-26T07:29:00.360 に答える
0

コールバック機能内のアプリデリゲートでこれを呼び出してください

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {

      UINavigationController *navControl = [[[self tableViewController] viewControllers] objectAtIndex:lastObject]; //
         id Obj = [[navControl viewControllers] lastObject];
                if([Obj isKindOfClass:[Required class]])
                {
                   [Obj reloadDataOfTable];// made an function to desired class.
                }
}
于 2012-06-26T07:38:38.610 に答える