반응형
앱의 비밀번호 입력 페이지등을 만들다 보면
뒤로가기 버튼을 막아야 하는 경우가 있다.
이 경우 platform에서 제공하는 뒤로가기 버튼 Action을
재정의하여 차단한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // Property used to store the callback of the event handler to unsubscribe to it when leaving this page public unregisterBackButtonAction: any; constructor(...) { ... } ionViewDidEnter() { this.initializeBackButtonCustomHandler(); } ionViewWillLeave() { // Unregister the custom back button action for this page this.unregisterBackButtonAction && this.unregisterBackButtonAction(); } public initializeBackButtonCustomHandler(): void { this.unregisterBackButtonAction = this.platform.registerBackButtonAction(() => { this.customHandleBackButton(); }, 10); } private customHandleBackButton(): void { // do what you need to do here ... } // Property used to store the callback of the event handler to unsubscribe to it when leaving this page public unregisterBackButtonAction: any; constructor(...) { ... } ionViewDidEnter() { this.initializeBackButtonCustomHandler(); } ionViewWillLeave() { // Unregister the custom back button action for this page this.unregisterBackButtonAction && this.unregisterBackButtonAction(); } public initializeBackButtonCustomHandler(): void { this.unregisterBackButtonAction = this.platform.registerBackButtonAction(() => { this.customHandleBackButton(); }, 10); } private customHandleBackButton(): void { // 뒤로가기 버튼 Action 재 정의 } | cs |
반응형