I am trying to add a header to the table view which is a NSLocalized String
. I tried doing this ,
self.tableView.tableHeaderView = NSLocalizedString("title", comment : "") as? UIView
But an error appeared that "Cast from type String
to unrelated type UIView
always fails". I tried without type casting as well and then the error was "Cannot convert type 'String' to the type UIView
". can anyone help me in adding this header to the tableView
? Thank you in advance.
A view that presents data using rows in a single column.
You need to set the view not string.
You can set label in view and set that view in table header.
var view1: UIView = UIView.init(frame: CGRectMake(0, 0, 320, 600));
var label: UILabel = UILabel.init(frame: CGRectMake(0, 0, 320, 600))
view1.addSubview(label);
self.tableView.tableHeaderView = view1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With