iOS 버그 리포트 - Segue 연결 후 prepare()가 오작동 하는 경우

in #ios6 years ago

증상

UITableView에서 Cell을 클릭시 다음 페이지로 넘어가거나 Navigation bar에서 버튼을 클릭해서 다음페이지로 넘어가는 경우 이렇게 버튼과 Cell에서 직접 Segue를 연결해줄 것이다.
ios_segue_1.png
ios_segue_2.png

그리고 Segue에 id값을 지정해주고
ios_segue_4.png

prepare() 메서드를 통해 지정해둔 ViewController가 열리기 직전 작업을 작성해준다.

https://gist.github.com/JaeBeomLee/943b73a88deb7d737e1789718402e2a6

그런데 이상하게 prepare() 메서드가 제대로 작동하지 않는다. 분명 거쳐가긴 하는데 if문도 제대로 동작하지 않는다.

해결 방법

아직 iOS를 시작한지 얼마 안되었고 급하게 제출 해야 하는 앱이다 보니 원인에 대해서 정확히 찾아보진 못했다.
해결방법은 간단하다.

우선 기존 Segue를 지워준다.

Segue를 버튼이나 Cell에서 직접 추가하지 말고 ViewController를 통해 추가한다.
ios_segue_3.png

그리고 버튼이나 Cell을 클릭할 때 Prepare이 작동 할 수 있도록 클릭 정의 메서드에서 self.performSegue() 메서드를 추가해준다.

(그 외 Segue에 id를 지정하는 것, prepare작성은 기존과 동일하다.)

이 글이 뉴비 iOS 개발자에게 많은 도움이 되길바라며 BLooi의 버그 리포트는 이만...

Sort:  

Congratulations @blooi! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

헐..대단하시네요!
개발자 세계는 마치 다른 은하계에서 온 느낌? ^_^

Congratulations @blooi! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 70272.86
ETH 3773.70
USDT 1.00
SBD 3.82