Skip to content
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

iOS Study #1

Open
junnegeem opened this issue Feb 14, 2020 · 0 comments
Open

iOS Study #1

junnegeem opened this issue Feb 14, 2020 · 0 comments

Comments

@junnegeem
Copy link
Collaborator

junnegeem commented Feb 14, 2020

iOS STUDY

  • 문제 인식

    1. IBOutlet할 버튼이 너무 많다!
    2. 모든 버튼을 일일이 boderWidth와 boderColor를 줄 수 없다!!
  • 가설 설정

    IBOutlet을 한번에 모을 수 있는게 있지 않을까?

  • 구글링 및 해결

    이전코드

' @IBOutlet weak var wineBtn: UIButton!

@IBOutlet weak var beerBtn: UIButton!

@IBOutlet weak var goodTasteHouseBtn: UIButton!

@IBOutlet weak var cafeBtn: UIButton!

@IBOutlet weak var artGalleryBtn: UIButton!

@IBOutlet weak var museumBtn: UIButton!

@IBOutlet weak var consertBtn: UIButton!

@IBOutlet weak var shoppingBtn: UIButton!'

func setBorderWidth() {

        self.wineBtn.layer.borderWidth = 1
        self.wineBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.beerBtn.layer.borderWidth = 1
        self.beerBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.goodTasteHouseBtn.layer.borderWidth = 1
        self.goodTasteHouseBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        
        self.cafeBtn.layer.borderWidth = 1
        self.cafeBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.artGalleryBtn.layer.borderWidth = 1
        self.artGalleryBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.museumBtn.layer.borderWidth = 1
        self.museumBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.consertBtn.layer.borderWidth = 1
        self.consertBtn.layer.borderColor = UIColor.mainPurple.cgColor
        
        self.shoppingBtn.layer.borderWidth = 1
        self.shoppingBtn.layer.borderColor = UIColor.mainPurple.cgColor

}

이후코드

' @IBOutlet var collectionBtn: [UIButton]!

'

' for button in self.collectionBtn {

        button.layer.borderWidth = 1
        button.layer.borderColor = UIColor.mainPurple.cgColor
    }

'

스크린샷 2020-02-14 오후 4 29 17

한 방으로 해결 가능!!!

스크린샷 2020-02-14 오후 4 17 54

iOS에서 화면 전환 개념

  1. 뷰 컨트롤러의 뷰 바꿔치기
    • 제한적으로 사용
  2. 뷰 컨트롤러에서 다른 뷰 호출해서 전환하기
  3. 네이게이션 컨트롤러 사용하기
  4. 세그웨이 사용하기(쓰지 말래요)

1번을 제외한 나머지는 뷰 컨트롤러를 호출하는 방식으로 이루어진다. 덮는다는 뜻!! - 참조관계가 성립

화면 전환은 두 가지 특성을 가짐

  • 다음화면으로 이동하는 방법과 이전 화면으로 돌아가는 방법이 다름

  • 화면 전환 방식에 따라 이전 화면으로 되돌아가는 방법이 다름

    즉, 다음 화면 가면 +1, 이전화면 오면 -1 이 되어야하는데, +1 그리고 +1 이 되면 +2가 되버림. - 충돌이 생길 수 있다

뷰 컨트롤러 직접 호출에 의한 화면 전환

뷰 컨트롤러는 UIViewController 클래스를 상속받는데, 그 안에 정의된 메소드 Present를 사용!!

animated는 화면 전환할 때 필요에 따라 애니메이션 효과를 주는 것!

Completion은 화면 전환이 완전히 끝난 후에 실행할 구문이 있으면, 클로저나 함수 형식으로 작성해, 호출할 때 쓴다.

Ex) present(호출할 뷰 컨트롤러, animated: true, completion:nil)

스크린샷 2020-02-15 오후 12 39 22

스크린샷 2020-02-15 오후 12 39 24

이 프리젠트 메소드는 뷰 컨트롤러 위에 뷰 컨트롤러는 얹는 방식!! 돌아갈때는 dismiss 메소드를 사용한다~

덮고 있던 화면을 걷어내는 것!!

네비게이션 컨트롤러를 이용한 화면 전환

네비게이션 바가 내장되어 있는 특별한 종류의 뷰 컨트롤러!

계층적 구조를 관리하는 역할이다.

첫번째 뷰 컨트롤러인 루트 뷰 컨트롤러를 기준으로 스택을 쌓는다.

이때는 뷰 컨트롤러를 추가할때는 pushViewController(_:animated:), 제거할때는 popViewController(animated:)메소드를 사용한다.

스크린샷 2020-02-15 오후 12 39 24

스크린샷 2020-02-15 오후 12 39 39

다음 스터디 주제 : imagePicker 사용법 ,progress bar 애니메이션, 정규식 사용, delegate를 이용한 회원가입 제한 !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant