0
I’m trying to create a table within a view. So that when the user is in view1 and presses a button open a smaller view2 inside view1 and choose one of the table data and loading transports the selected data to view1.
I started doing this in view1:
carViewSelect.frame = CGRectMake(10, 70, 355, 580)
carViewSelect.layer.borderColor = UIColor.blueColor().CGColor
carViewSelect.layer.borderWidth = borderSizeView
carViewSelect.layer.cornerRadius = 10
carViewSelect.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.9)
view.addSubview(carViewSelect)
listCars.frame = CGRectMake(10, 35, 340, 490)
listCars.registerClass(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
listCars.numberOfRowsInSection(5)
var indexPath = NSIndexPath()
let cell : UITableViewCell = listCars.dequeueReusableCellWithIdentifier(cellIdentifier)! as UITableViewCell
cell.textLabel!.text = "hello WOrld"
cell.textLabel?.textColor = UIColor.blackColor()
listCars.indexPathForCell(cell)
listCars.backgroundColor = UIColor.grayColor()
carViewSelect.addSubview(listCars)
However the result I got was an empty table, as shown in the image:
The idea would be to put an image at the beginning of Cell, then a label and then another image. The data to fill the table see in a Nsmutablearray
Already defined in viewDidLoad delegate and datasource?
– JdsMedeirosBR
Já avencei um pouco e no controlView instanciei a tabela da seguinte forma 'let ab : TableView = TableView(frame: CGRectMake(10, 35, 340, 490))
 carViewSelect.addSubview(ab)
 ab.addActionBar(self)' . and this way I already managed to add the desired results in the table, however the didSelectRowAtIndexPath method is not being called when I click on a "Cell"
– HideCode
Put the code on that part to get an idea of what’s going on...
– JdsMedeirosBR
@Jadsonmedeiros, I already got the result I wanted, I only have a problem when I enter view2 in 1st place I will load the table with the data, and when it left I would like to clean the table. Because if you call view2 again it will load the table again and will duplicate the results in the table. Can you empty the table when you left the view? Thank you
– HideCode
Are you using a database? if yes or no, the procedure is the same... you can do the following, since you supposedly use an array with strings to popular the view2, you can in the command that makes you go back to view1, delete all the data of the array that populates the view2. When you are in view1 and click to show view2, view1 fills the array with the necessary data for view2 and not duplicated and sends to view2 show normally.
– JdsMedeirosBR
I’m using a database, so whenever I call view2, I pull the data from the comic book. And how do I erase all data from the array is that I have done it in a few ways and have not succeeded
– HideCode
Seuarray.removeAll() to delete the array, however you have to do the procedure:when you go from view1 to view2, first delete all data from the database and then enter new data, so always the database will be updated and without repeated data.
– JdsMedeirosBR