Reputation: 41
I want to change the uitableview's stype in viewdidiload in swift. but it gives an error "Can not assign the result of this expression
@IBOutlet weak var tableview: UITableView!
let names = ["Gulshan","Mitesh","Rahul","roma"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any xadditional setup after loading the view, typically from a nib.
tableview.style = UITableViewStyle.Grouped
}
Upvotes: 2
Views: 2646
Reputation: 61
You can do that while initializing in init with frame method.
See example:
var tableview1 = UITableView(frame: CGRectMake(0, 0, 160,320), style: UITableViewStyle.Grouped)
Upvotes: 6
Reputation: 143
You can't change the tableview style dinamically, you have to do it in your xib file or storyboard if you have one. If you don't use a storyboard or a xib, and prefer to create the tableview programmatically, specify the style while creating the tableview using the - initWithFrame:style: method.
Bye D.
Upvotes: 2