Wednesday, 15 June 2011

ios - Reload TableView data from AppDelegate.m? -



ios - Reload TableView data from AppDelegate.m? -

i seek reload tableview appdelegate

in appdelegate.m, in method in charge force notification, "didreceiveremotenotification" phone call uialertview everytime when notification arrives.

uialertview *alertview = [[uialertview alloc] initwithtitle:@"notification received" message:[nsstring stringwithformat:@"%@", titlemsg] delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; alertview.delegate = self; [alertview show];

and when user click "ok" button, should reading of database , reload tableview

// reload table when user click "ok" button in alert - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if ([alertview.title isequaltostring:@"notification received"]) { if (buttonindex == [alertview cancelbuttonindex]) { // stop sound notifications [self stopsoundfornotifications]; // refresh table messages accueilviewcontroller * avc = [[accueilviewcontroller alloc] init]; [avc readmsgsfromdb]; [avc reloadtablemsgsreceived]; [[nsnotificationcenter defaultcenter] postnotificationname:@"readmessagesfromdb" object:nil]; [[nsnotificationcenter defaultcenter] postnotificationname:@"reloaddatafromdelegate" object:nil]; } }

}

in header added protocol uialertviewdelegate

do have ideas? thanks

you set status on cancel button instead of set status on ok button - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex {

if ([alertview.title isequaltostring:@"notification received"]) { if (buttonindex == [alertview okbuttonindex]) { // fire notification // stop sound notifications [self stopsoundfornotifications]; // refresh table messages accueilviewcontroller * avc = [[accueilviewcontroller alloc] init]; [avc readmsgsfromdb]; [avc reloadtablemsgsreceived]; [[nsnotificationcenter defaultcenter] postnotificationname:@"readmessagesfromdb" object:nil]; [[nsnotificationcenter defaultcenter] postnotificationname:@"reloaddatafromdelegate" object:nil]; } }

ios objective-c xcode

No comments:

Post a Comment