페이지

2017년 11월 3일 금요일

Dynamically Sized Table View Header or Footer Using Auto Layout

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    // Dynamic sizing for the header view
    if let headerView = tableView.tableHeaderView {
        let height = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
        var headerFrame = headerView.frame

        // If we don't have this check, viewDidLayoutSubviews() will get
        // repeatedly, causing the app to hang.

        if height != headerFrame.size.height {
            headerFrame.size.height = height
            headerView.frame = headerFrame
            tableView.tableHeaderView = headerView
        }
    }
}


http://collindonnell.com/2015/09/29/dynamically-sized-table-view-header-or-footer-using-auto-layout/

2017년 10월 22일 일요일

notice: distributing ad hoc ipa

Building adhoc ipa file, You must check "Manually manage signing".
and you just choose its adhoc app provisioning file and certificate

(x) Automatically manage signing
(o) Manually manage signing


2017년 10월 20일 금요일

uitableview header top spacing issue

self.automaticallyAdjustScrollViewInsets = false


2017년 10월 10일 화요일

content hugging vs content compression resistance priority

https://stackoverflow.com/questions/15850417/cocoa-autolayout-content-hugging-vs-content-compression-resistance-priority/16281229#16281229

down voteaccepted
Quick summary of the concepts:
  • Hugging => content does not want to grow
  • Compression Resistance => content does not want to shrink
and an example:
Say you've got button like this:
[       Click Me      ]
and you've pinned the edges to a larger superview with priority 500.
Then, if Hugging priority > 500 it'll look like this:
[Click Me]
If Hugging priority < 500 it'll look like this:
[       Click Me      ]
If superview now shrinks then, if the Compression Resistance priority > 500, it'll look like this
[Click Me]
Else if Compression Resistance priority < 500, it could look like this:
[Cli..]
If it doesn't work like this then you've probably got some other constraints going on that are messing up your good work!
E.g. you could have it pinned to the superview with priority 1000. Or you could have a width priority. If so, this can be helpful:
Editor > Size to Fit Content

2017년 9월 18일 월요일

Setting Custom View Properties

1. add keyword @IBDesignable before class
2. add Keyword @IBInspectable properties

ex ) MyView.swift


@IBDesignable MyView : UIView {

    var titleLabel:UILabel?

   

    @IBInspectable var textColor : UIColor! {

        didSet {

            if self.titleLabel != nil {

                self.titleLabel.textColor = textColor

            }

        }

    }

}