UINavigationControllerのnavigationBar領域をViewで覆うやり方
ある処理をする際に他画面に遷移されたりボタン操作をされたくなかったので新たにViewを作成して対象画面にaddSubViewして覆っていたのだがnavigationBarの領域にあるボタンは押せてしまっていた。
navigationBar領域を覆えないコード
CGRect frame = self.view.frame; UIView *coverView = [[UIView alloc] initWithFrame:frame]; //生成したViewで現在の画面を覆う [self.view addSubview:coverView];
navigationBar領域も含めて覆うにはAppDelegateのwindowに対してaddSubViewしてやらなければいけない。
navigationBar領域を覆えるコード
CGRect frame = [UIScreen mainScreen].bounds;
UIView *coverView = [[UIView alloc] initWithFrame:frame];
//生成したViewで現在の画面を覆う
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window addSubview:coverView];