プロジェクトで SWRevealViewController を使用して、アプリのスライド アウト メニューを作成しています。
スライドアウトが保持するメニューで現在アクティブなリンクを強調表示することは可能ですか?
ページ参照識別子を sidebarviewcontroller に送信しようとしましたが、ビューはアプリの起動時に一度だけ読み込まれ、その後単に表示および非表示になるため、これは効果がないようです。
どんな助けでも大歓迎です。
乾杯
プロジェクトで SWRevealViewController を使用して、アプリのスライド アウト メニューを作成しています。
スライドアウトが保持するメニューで現在アクティブなリンクを強調表示することは可能ですか?
ページ参照識別子を sidebarviewcontroller に送信しようとしましたが、ビューはアプリの起動時に一度だけ読み込まれ、その後単に表示および非表示になるため、これは効果がないようです。
どんな助けでも大歓迎です。
乾杯
これが実際に関連する質問かどうかはわかりませんSWRevealViewController
。ほとんどの場合、背面/底面/メニュー ビューは実際にはUITableViewController
. その場合、解決策は簡単です。UITableViewController
選択した状態を記憶するように要求します。
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
}
この解決策は次のとおりです: UITableView は戻り時に行を選択したままにしない
私は NSNotification センターを使用してこれを行うことになりました。各View Controllerの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 *)通知{
すべてのラベルを太字以外のフォントにリセットしました
// 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];
}