ios개발/프로젝트

<ios프로젝트2>뷰컨 참조해 보기, UIStoryBoard , LayoutSubView

studying develop 2020. 3. 23. 04:14
class nDetailVC: UIViewController {
    

    var nview = DetailImgView()
    //MARK: - Model , 해당 클래스 스태틱 인스턴스로 옮기자.
    //var GalleryDetailInstance = GalleryDetail()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        print("in viewDidLoad \(self)")

in viewDidLoad <kakao_subject_kimdonghwan.nDetailVC: 0x1020a2450>

 

public class DetailHttpElement{
    //MARK: - 여기서 프로퍼티 옵저버 사용이 가능한가? 예제랑 조금 다른게, 여기 값들은 한개의 라벨에서만 사용되지 않을 수도 있긴하다. 용도가 다양할수도.
    
    var href = ""
    var productTitle = ""{
        didSet{
            DispatchQueue.main.async{
                guard let viewController : nDetailVC = UIStoryboard(name: "nDetailVC", bundle : nil).instantiateInitialViewController() else{
                    fatalError("could not load UIstoryBoard")
                }
                print("viewController : \(viewController)")
                print("viewController.nview.title_lb : \(viewController.nview.title_lb)")
                //MARK:- viewController.nview.title_lb.text 이게 왜 도대체 nil이지??
                print("viewController.nview.title_lb.text : \(viewController.nview.title_lb.text)")
                print("333")
                viewController.nview.title_lb.text = "123"
                print("in property var")
            }
        }
        
    }

viewController : <kakao_subject_kimdonghwan.nDetailVC: 0x1020a9080>

viewController.nview.title_lb : <kakao_subject_kimdonghwan.EXUILabel: 0x1020a97f0; baseClass = UILabel; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <_UILabelLayer: 0x282802440>>

viewController.nview.title_lb.text : nil

 

 

왜 nDetailVC의 주소가 다르지?? !!@#!@#?!@#?!@#? 하

 


Class

UIStoryboard

An encapsulation of the design-time view controller graph represented in an Interface Builder storyboard resource file.

 

Declaration

class UIStoryboard : NSObject

Overview

A UIStoryboard object manages archived versions of your app's view controllers. At design time, you configure the content of your view controllers visually, and Xcode saves the data needed to recreate that interface in a storyboard file in your app's bundle. When you want to create a new view controller programmatically, first create a UIStoryboard object and specify the appropriate name and bundle information. Then use that object to instantiate the specific view controller that you want.

 

uistoryboard 객체는 앱의 뷰컨들의 아카이브드 버전을 관리합니다. 

 

During the instantiation process, UIStoryboard creates your view controller programmatically using its init(coder:) method. The storyboard passes the view controller's data archive to that method, which then uses the data to recreate the state of the view controller and its views. If you have a custom initialization method for your view controller, you can ask the storyboard to instantiate your view controller using a block you provide. You can use this block to call your custom initialization method, passing any extra data your view controller needs.

 

uistoryboardsms init으로 뷰컨을 새로 만듭니다. (난 이게 뷰컨 객체를 참조하는 줄...) 이미 존재하는 뷰컨 객체를 참조하는 걸 찾자.

 


[https://developer.apple.com/documentation/uikit/uiview/1622482-layoutsubviews]

Instance Method

layoutSubviews()

Lays out subviews.

 

Declaration

func layoutSubviews()

Discussion

The default implementation of this method does nothing on iOS 5.1 and earlier. Otherwise, the default implementation uses any constraints you have set to determine the size and position of any subviews.

 

Subclasses can override this method as needed to perform more precise layout of their subviews. You should override this method only if the autoresizing and constraint-based behaviors of the subviews do not offer the behavior you want. You can use your implementation to set the frame rectangles of your subviews directly.

 

섭클래스들은 이 메소드를 오버라이드 해서 섭뷰를 레이아웃하는데 사용할 수 있다. 이 메소드는 자동 크기 조절과 제한에 기반한 섭뷰들의 행동들이 내가 원하는 행동을 지원해 주지 못할때만 사용하라!. 이걸로 직접적으로 나의 섭뷰의 프래임을 세팅하는데 사용할 수 있다.

 

음 이 문장만으로 이해되기는 오토 콘스트레인트 같이 다른 곳에서 조절한 제한들 말고 다른 속성을 바꿀때 사용하라는거 같다.

 

You should not call this method directly. If you want to force a layout update, call the setNeedsLayout() method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call the layoutIfNeeded() method.