突出显示SWRevealViewController中的活动链接

我在我的项目中使用SWRevealViewController为我的应用程序创build一个滑出菜单。

是否可以突出显示滑出的菜单中的当前活动链接?

我试着发送一个页面引用标识符到sidebarviewcontroller,但它似乎没有效果,因为该视图只在应用程序启动时加载一次,然后简单地显示和隐藏。

任何帮助将非常感激。

干杯

我不确定这实际上是一个与SWRevealViewController有关的问题。 最有可能你的后/底/菜单视图是一个真正的UITableViewController 。 如果是这种情况,那么解决scheme很简单。 请求UITableViewController记住它的select状态。

 - (void)viewDidLoad { [super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. self.clearsSelectionOnViewWillAppear = NO; } 

这个解决scheme来自: UITableView不保留行返回时select

我最终使用NSNotification中心来做这件事。 在每个视图控制器的viewWillAppear我添加…

 // Send notification containing page reference to be picked up by sidebar view controller NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"homePage" forKey:@"page"]; [[NSNotificationCenter defaultCenter] postNotificationName: @"activePage" object:nil userInfo:userInfo]; 

在SidebarViewController viewDidLoad中拾取了…

 // Pick up the page reference notification and trigger receivePageReference function [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivePageReference:) name:@"activePage" object:nil]; 

然后在receivePageReference操作中…

– (void)receivePageReference:(NSNotification *)notification {

我将所有标签重置为非粗体字体

 // Reset all labels to non-bold font UILabel *homeLabel = (UILabel *)[self.view viewWithTag:12]; homeLabel.font = [UIFont fontWithName:@"Colaborate-Thin" size:19]; UILabel *liveLabel = (UILabel *)[self.view viewWithTag:13]; liveLabel.font = [UIFont fontWithName:@"Colaborate-Thin" size:19]; UILabel *racesLabel = (UILabel *)[self.view viewWithTag:14]; racesLabel.font = [UIFont fontWithName:@"Colaborate-Thin" size:19]; 

等等..

并将相应的页面引用设置为粗体的标签…

 NSDictionary *notificationInfo = notification.userInfo; if ([[notificationInfo objectForKey:@"page"] isEqualToString:@"homePage"]){ UILabel *homeLabel = (UILabel *)[self.view viewWithTag:12]; homeLabel.font = [UIFont fontWithName:@"Colaborate-Medium" size:19]; }