-
Notifications
You must be signed in to change notification settings - Fork 16
계산기 [STEP 3] D.O, Sunny #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
doshkor
wants to merge
26
commits into
tasty-code:1_d.o
Choose a base branch
from
doshkor:STEP3
base: 1_d.o
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@protocorn93
[써니]☺️ 설날이 껴있고, 프로젝트가 저희 생각보다 어려워서 그런지 유난히 힘들었던 STEP3 였어요🥲 일단 요구사항에 적혀진 기능들이 돌아갈 수 있도록 코드를 구현하였지만 깔끔히 코드를 작성하지는 못한것 같아 매우 아쉬워요ㅠㅠ 주말에 조금 더 시간을 내서 더 나은 코드를 작성해볼게요!
안녕하세요 콘
[디오]
콘! 안녕하세요🙋
STEP 1 부터 앞선 프로젝트와 달리 UML을 제시받고 진행하다 보니 많이 헤매게 되었던 프로젝트였던거 같아요.😭 STEP 3 에서는 써니와 함께 고민한 부분이 많았는데, 만족할 만큼 완성하지 못해 너무 아쉽게 느껴져요. 정성스러운 리뷰 너무 감사드리고 다음에 또 뵈었으면 좋겠어요. 감사합니다🤗
구현 사항
숫자
연산
UI
구현 세부사항 및 고민
스택 추가시 자동스크롤 하는 코드
스크롤 뷰의 visibleSize 와 contentSize 를 비교합니다.
Case1)
visibleSize≥contentSize인 경우화면을 이동할 필요가 없어요
그래서 오프셋을
x:0, y: 0으로 보여주게 되요Case2)
visibleSize<contentSize인 경우[ 전체 높이(
contentSize) 에서 스크롤 뷰 화면의 높이(visibleSize) 만큼 빼준 값 ]을 오프셋으로 설정하여 setContentOffset 을 하였습니다.scrollView.contentSize.height - scrollView.visibleSize.height + labelHeight위 Case2) 에서 스크롤뷰에 스텍뷰를 추가한 후 자동스크롤을 의도하였는데요
로직은 “ 1) 스크롤뷰에 스텍뷰를 추가한다. 2) 오프셋 계산을 한다 3) 화면을 이동한다 “ 순으로 진행되어요
그렇다면 추가한 것에 맞춰서 자연스럽게 이동이 될 것으로 생각하였는데.. 딱 추가한 스텍뷰가 보이지 않는 만큼만 화면이 스크롤 되더라구요!
제가 생각하기에는 뷰가 화면에 로드된 후에 스텍뷰를 스크롤뷰에 추가하더라도.. 추가 전후의 스크롤뷰의 height 는 변경되지 않아서 이런 현상이 발생하는 것인가..? (다시 뷰가 로드될 때 이전에 추가된 스텍뷰를 반영하여 스크롤뷰의 height 가 늘어나는 것일까?) 라고 조심스럽게 생각해 보았습니다.
혹시 콘이 생각하시기에는 어떨까요??🙀
UIStackView 추가 및 삭제
저희는 계산기에서 연산을 입력하면, 연산자와 숫자 UILabel이 있는 stackView가 scrollView에 쌓이게 구현했어요. 동일한 구조의 stackView가 반복되기 때문에 CustomStackView를 만들었어요.
⁺⁄₋ 부호처리
연산 결과값 Formatter
저희는 결과값에 대한 위와 같은 요구사항을 적용하기 위해 NumberFormatter()을 사용했어요.
numberFormatter를 사용하던 중에 문제가 발생하였는데 질문드리고 싶어요!문제가 발생한 코드
operandLabel은 계산기에서 입력한 숫자가 나타나는 곳이에요1,000,000콤마형식을 취하고 싶어서numberFormatter를 사용하고자 했어요발생한 문제
operandLabel.text에numberFormatter(for:)값을 넣었는데 화면에 아무런 값이 나오지 않아요!확인한 점
userOperandInput으로 잘 들어가지만 numberFormatter.string(for:) 메서드에 넣으면 nil 값만 나오게 되는데 이게 어떻게 발생하는 현상인지 잘 모르겠습니다 😭