Reputation: 194
I am designing a one-to-one chatting interface using table view. This table view is modified to show bubbles as some new message arrives. The new message arrives through a push-notification in this case. I call following code in my function which receives message through the push notification:
-(void)messageReceived: (NSString *)message{
_message=[message retain];
[tableView reloadData];
}
However, it seems this does not reload my table view.
If I place the call for reloadData
in the viewDidAppear
function, it reloads fine. It also reloads fine, if I place the reloadData
call in a function whose return type is IBAction
(ex: a function binding to button click)
What could be the reason for reloadData
to not get triggered through custom declared functions ?
Upvotes: 0
Views: 190
Reputation: 6021
may be you have not Connect the Tableview with table view Delegates and Datasource
Objective-C
@interface YourClass : UIViewController <UITextFieldDelegate, UITextViewDelegate>
yourtableview.delegate = self;
yourtableview.dataSource = self;
[tableView reloadData];
Swift 3
class YourClass: UIViewController , UITableViewDelegate, UITableViewDataSource
yourtableview.delegate = self
yourtableview.dataSource = self
yourtableview.reloadData()
the other way is! for Swift and Objective-C both. Right Click on the Table view and drag and drop the delegates.
Upvotes: 1
Reputation: 202
reloaddata method is called but the trick here that you didn't add the incoming message to the datasource that the tableview load from !
Upvotes: 2