UITableViewWrapperView and UITableView size differs with autolayout

后端 未结 7 2011
一生所求
一生所求 2020-12-28 16:38

I am building a chat. Everything seem to be quite ok but I bumped into sort of \'buggy\' problem.

i got UIViewController with UITextView bar for entering message and

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 16:56

    After small investigation I have found this solution with setting all the safeAreaInsets and layoutMargins on the UITableView to zero:

    Swift 4 snipset:

    class CustomTableView: UITableView {
    
    	override var safeAreaInsets: UIEdgeInsets {
    		get {
    			return .zero
    		}
    	}
    
    	override var layoutMargins: UIEdgeInsets {
    		get {
    			return .zero
    		}
    
    		set {
    			super.layoutMargins = .zero
    		}
    	}
    }

    The main problem is safeAreaInsets introduced in tvOS 11.0 - the UITableViewWrapperView just took the properties from the parent view (UITableView) and renders the content with safeAreaInsets.

提交回复
热议问题