0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

(Objective-C/Swift)iOS13 presentViewControllerしたViewControllerをスワイプで閉じられないようにする処理(storyboard、segue遷移版)

0
Posted at

こういう人に向けて発信しています。

・ViewControllerを表示して勝手に閉じられてしまって困っている人
・seuge遷移でどうすればいいかわからない人
・Swift中級者/Objective-C中級者

前回の記事:【Objective-C/Swift】iOS13にてpresentViewControllerしたViewControllerをスワイプで閉じられないようにする処理(コード版)

前回はコードで画面遷移する際に
・画面サイズをフルスクリーンと指定する。
・スワイプで画面が下がらないようにする

を対応しました。

しかしながらコードではなくsegue遷移していた場合については、
フォローし切れていなかったので改めて補足を分けて投稿いたします。

segueで遷移する先のViewControllerをスワイプで下げられないようにする方法を記載します。

Objective-C

//segue遷移を行う
- (void)gotoNextSegue{
   [self performSegueWithIdentifier:@"segueIdentifer" sender:self];
}



//segueで画面遷移する直前に呼び出される
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
   CustomViewController *customVC = (CustomViewController*)segue.destinationViewController;
   customVC.modalInPopover = YES;  //YESにするとスワイプで消えなくなる。
}

Swift

    //segue遷移を行う
   func gotoNextSegue() -> Void {
       performSegue(withIdentifier: "segueIdentifer", sender: nil)
   }

   //segueで画面遷移する直前に呼び出される
   override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
       let customVC  = segue.destination as! CustomViewController
       customVC.isModalInPresentation = true;
   }
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?