ios - how to get the screenwidth in a UITableViewCell? -
i layout uitableviewcell. need know screenwidth of device. in viewcontroller screenwidth with:
self.view.frame.width
in case 375.
when fetching width in uitableviewcell width of 320:
class cellresult: uitableviewcell { ... ... override init(style: uitableviewcellstyle, reuseidentifier: string!) { super.init(style: style, reuseidentifier: reuseidentifier) let rowwidth=frame.width; // <--- 320
i prevously initialized uitableview frame of width of 375.
how real width of device in uitableviewcell ?
as mentioned in comments, can size of screen using uiscreen
; however, think proper place access actual size of cell (in case need position own custom views, etc.), after layouts subviews. in other words, can override layoutsubviews()
method in cell subclass , whatever need that's based on cell's frame there frame @ proper size.
Comments
Post a Comment