Hi,
How I can identifier the name the Cells.
I Have 3 cell, (Hotels, flights, Cars)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {
let cell: UITableViewCell
if hotels.count 0 {
cell = getHotelsCell(tableView, indexPath: indexPath)
if cars.count 0 {
cell = getCarsCell(tableView, indexPath: indexPath)
}
if flights.count 0 {
cell = getFlightsCell(tableView, indexPath: indexPath)
}
return cell
}
}
I have 3 objects hotels, cars, flights.
In my case the indexPath is wrong, because i Have:
1 hotels
2 flights
1 Cars
In my didSelectRowAt indexPath.row is not correct.
for access object.
I put in each cell on Text for number of index(This work) but i cant access cell.lbIndexPath.text.
I try
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = self.tableView(tableView, cellForRowAt: indexPath) as? UITableViewCell {
/* this line cell is not identifier cell.lbIndexPath.text */
/* this if is wrong i know, this logic for index path */
if tableViewCell.name = Hotels {
var index = cell.lbIndexPath.text
open view details - Hotels[index]
}
if tableViewCell.name = flights {
var index = cell.lbIndexPath.text
open view details - flights[index]
}
if tableViewCell.name = Cars {
var index = cell.lbIndexPath.text
open view details - flights[index]
}
}
tnks, a million.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Hi,
Ha have create one button in center the my tabbar, in the tabBarcontroller.swift.
I need Hidden this button in my second bar (viewcontroller), but i can't access the button for hidden.
how can i do this.
var button = UIButton(type: UIButton.ButtonType.custom)
override func viewDidLoad() {
super.viewDidLoad()
translateViews()
let buttonImage = UIImage(named: "AddWhite48dp")
button.frame = CGRect(x: 0.0, y: 0.0, width: buttonImage!.size.width, height: buttonImage!.size.height);
button.setBackgroundImage(buttonImage, for: UIControl.State())
button.backgroundColor = UIColor(red: 35.0/255.0, green: 49.0/255.0, blue: 57.0/255.0, alpha: 1)
button.center = self.tabBar.center
button.center.y -= self.tabBar.frame.height/3
button.layer.cornerRadius = button.frame.size.width/2
button.clipsToBounds = true
button.addTarget(self, action: #selector(MainTabController.showMenu(_:)), for: UIControl.Event.touchUpInside)
self.view.addSubview(button)
}
func hiddenButton (hidden:Bool){
button.isHidden = hidden
}
I try create a func in my tabbarcontroller.swift.
but is not work for me. i can't access func in the second view.
Tks a lot.