使用动态菜单数据的 MF 侧菜单问题
MF Side menu problems using dynamic Menu data
我有一个问题,因为我想把动态数据放在我的侧边菜单中
我将 [MFSideMenu]
与 Xcode Version 8.2.1
一起用于 ios 10.2.1
,我创建了一个 SideMenuViewController : UITableViewController
,我在侧边菜单中设计和填充数据。
当我启动应用程序时,它会正确显示所有数据。登录后需要更新侧边菜单数据。我在登录后更新了一个菜单数组,但是 table 视图显示了之前的数据。
使应用程序显示正确数据的唯一方法是重新启动应用程序。
所以我的问题是哪里出了问题,是否可以在侧边菜单中使用动态数据?如果可以,实现此目的的最佳方法是什么?
您需要使用 NSNotificationCenter 来刷新数据。
在SideMenuViewController的ViewDidLoad中加入
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveTestNotification:)
name:@"refreshData"
object:nil];
2。在 SideMenuViewController
中添加选择器方法
- (void) receiveTestNotification:(NSNotification *) notification
{
[tableview reloadData];
}
3。现在 post 登录时通知
[[NSNotificationCenter defaultCenter]
postNotificationName:@"refreshData"
object:self];
我有一个问题,因为我想把动态数据放在我的侧边菜单中
我将 [MFSideMenu]
与 Xcode Version 8.2.1
一起用于 ios 10.2.1
,我创建了一个 SideMenuViewController : UITableViewController
,我在侧边菜单中设计和填充数据。
当我启动应用程序时,它会正确显示所有数据。登录后需要更新侧边菜单数据。我在登录后更新了一个菜单数组,但是 table 视图显示了之前的数据。
使应用程序显示正确数据的唯一方法是重新启动应用程序。
所以我的问题是哪里出了问题,是否可以在侧边菜单中使用动态数据?如果可以,实现此目的的最佳方法是什么?
您需要使用 NSNotificationCenter 来刷新数据。
在SideMenuViewController的ViewDidLoad中加入
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveTestNotification:) name:@"refreshData" object:nil];
2。在 SideMenuViewController
中添加选择器方法 - (void) receiveTestNotification:(NSNotification *) notification
{
[tableview reloadData];
}
3。现在 post 登录时通知
[[NSNotificationCenter defaultCenter]
postNotificationName:@"refreshData"
object:self];