使用动态菜单数据的MF侧菜单问题 [英] MF Side menu problems using dynamic Menu data

查看:72
本文介绍了使用动态菜单数据的MF侧菜单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,因为我想在侧边菜单中放入动态数据 我正在将[MFSideMenu]Xcode Version 8.2.1一起用于ios 10.2.1,并创建了一个SideMenuViewController : UITableViewController,在其中设计并填充侧面菜单中的数据.

I have a problem because I want to put dynamic data in my side menu I am using [MFSideMenu] with Xcode Version 8.2.1 for ios 10.2.1 and I have created a SideMenuViewController : UITableViewController where I design and populate data in my side menu.

启动应用程序时,它会正确显示所有数据.登录后需要更新侧菜单数据.登录后我将更新菜单数组,但表视图显示了以前的数据.

When I start the app it shows all the data correctly. After login need to update the side menu data. i'm updating a menu array after login but table view showing the pervious data.

让应用显示正确数据的唯一原因是我重新启动了应用.

The only thing that makes the app show the correct data, is if I restart the app.

所以我的问题是什么会出错,是否可以在侧面菜单中使用动态数据,如果可以,那么实现此目的的最佳方法是什么?

So my question what can be wrong, is it possible to use dynamic data in the side menu, and if so what is the best way to achieve this?

推荐答案

您需要使用NSNotificationCenter刷新数据.

You need to use NSNotificationCenter for refresh data.

  1. 在SideMenuViewController的ViewDidLoad中添加

  1. Add in SideMenuViewController's ViewDidLoad

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

2.在SideMenuViewController中添加选择器方法

2 . Add selector method in SideMenuViewController

 - (void) receiveTestNotification:(NSNotification *) notification
{
      [tableview reloadData];
}

3.现在在登录时发布通知

3 . Now post notification while Login

   [[NSNotificationCenter defaultCenter] 
    postNotificationName:@"refreshData" 
    object:self];

这篇关于使用动态菜单数据的MF侧菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆