Giter Club home page Giter Club logo

Comments (1)

yeahg-dev avatar yeahg-dev commented on August 30, 2024

기존에 viewDidLayoutSubviews()에서 preferredContentSize를 historyTableView의 contentSize와 동일하게 주면,
view의 safeAreaLayoutGuide와 준 제약 ( historyTableView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 7))과 충돌하게 되기때문에 constant만큼을 더한 사이즈를 preferredContentSize로 설정

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        self.preferredContentSize.height = self.historyTableView.contentSize.height + CGFloat(14)
    }

테이블뷰의 cellForRowAt에서 cell을 리턴하기전 self.view.setNeedsLayout()를 호출함

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        ...
        self.view.setNeedsLayout()
        
        return historyTableViewCell
    }

다음 업데이트사이클때 바뀐 뷰의 사이즈를 최종적으로 반영하여 한번만 레이아웃을 업데이트 하도록 수정함

여기서 layoutIfNeeded()를 호출하면 popover의 뷰의 사이즈가 없는채로 cellForRowAt을 리턴해버리게 됨.
다음 업데이트 사이클을 기다리지않고 당장 뷰의 layoutSubview()를 호출한다는 사실을 체감하게됨

from ios-project-manager.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.