In the same viewController I have a calendarTableViewthat represent the month's days. At cellForRowAti select the row corresponding to current day and call a function to populate timeSlotCollectionView. It all work but I have a little strange situation.
Case 1: Row height = auto and scrollPosition.none = timeSlotCollectionView don't follow cornerRadius
Case2: Row height = auto and scrollPosition.middle = Thread 1: EXC_BAD_ACCESS (code=2, address=0x659ef4) on calendarTableViewcell definition
Case3: Row height = 44 and scrollPosition.none = calendarTableViewcell don't follow cornerRadius
Case 4: Row height = 44 and scrollPosition.middle = calendarTableViewcell don't follow cornerRadius
Case 5: Row height = 60 and scrollPosition.none = calendarTableViewcell DOES follow cornerRadius
Case 6: Row height = 60 and scrollPosition.middle = calendarTableViewcell DON'T follow cornerRadius again..
I wouldn't mind row height of 60, but scrollPositionhas to be.middle or I wouldn't see the current day row..
Can you see what I'm doing wrong? I've searched other posts but I couldn't find anything that gave me a clue on what the problem was.
Many thanks as usual.
This is the calendarTableViewfunction:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "calendarCell", for: indexPath) as! CalendarTableViewCell
// Configure the cell...
let date = datesArray[indexPath.row]
print(date)
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day, .weekday], from: date)
cell.dayLabel.text = "\(String(describing: components.day!))" + " " + "\(dayNamesArray[components.weekday! - 1])"
cell.cellWeekday = components.weekday!
print("cell weekday is: \(cell.cellWeekday!)") // prints correct weekday
cell.cellId = "\(String(format:"%04d", components.year!))" + "\(String(format:"%02d", components.month!))" + "\(String(format:"%02d", components.day!))"
self.selectedDate = cell.cellId // used for time slots cellId
print("##################### selectedDate in tableview is :\(self.selectedDate) ")
// highlighting current day cell
if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
cell.dayLabel.backgroundColor = UIColor.red.withAlphaComponent(0.3)
// emulate user selecting the cell
tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableViewScrollPosition.none) // changing to .middle makes the tableview go looping
print(" ########################## selected cell weekday is: \(cell.cellWeekday!) #################### ")
// self.updateTimeSlots(selectedCell: cell)
// self.actualWeekday = cell.cellWeekday! // nil error
self.selectedDate = cell.cellId
// calculateOpenTimeSlots()
}
// let cornerRadius: CGFloat = 5
// cell.layer.cornerRadius = cornerRadius
// cell.clipsToBounds = true
// self.updateTimeSlots(selectedCell: cell)
return cell
}
I decided not to select the today row but only scroll calendarTableViewto have in that middle position instead. I also declare row height directly in heightForRowAt. calendarTableView now behaves as expected and cell is not directly selected, but highlighted as I actually wanted.
I hope that this will help others.
The final function is:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "calendarCell", for: indexPath) as! CalendarTableViewCell
let cornerRadius: CGFloat = 5
cell.layer.backgroundColor = UIColor.white.cgColor
cell.layer.cornerRadius = cornerRadius
cell.clipsToBounds = true
cell.dayLabel.textColor = UIColor.white
cell.dayLabel.layer.backgroundColor = UIColor.blue.withAlphaComponent(0.3).cgColor
cell.dayLabel.layer.cornerRadius = cornerRadius
cell.dayLabel.clipsToBounds = true
// Configure the cell...
let date = datesArray[indexPath.row]
print(date)
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day, .weekday], from: date)
cell.dayLabel.text = "\(String(describing: components.day!))" + " " + "\(dayNamesArray[components.weekday! - 1])"
cell.cellWeekday = components.weekday!
print("cell weekday is: \(cell.cellWeekday!)") // prints correct weekday
cell.cellId = "\(String(format:"%04d", components.year!))" + "\(String(format:"%02d", components.month!))" + "\(String(format:"%02d", components.day!))"
self.selectedDate = cell.cellId // used for time slots cellId
print("##################### selectedDate in tableview is :\(self.selectedDate) ")
// highlighting current day cell
if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
// cell.layer.backgroundColor = UIColor.red.withAlphaComponent(0.3).cgColor
cell.dayLabel.layer.backgroundColor = UIColor.red.withAlphaComponent(0.3).cgColor
// emulate user selecting the cell
// tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableViewScrollPosition.middle)
tableView.scrollToRow(at: indexPath, at: UITableViewScrollPosition.middle, animated: true)
print(" ########################## selected cell weekday is: \(cell.cellWeekday!) #################### ")
self.updateTimeSlots(selectedCell: cell)
// self.actualWeekday = cell.cellWeekday! // nil error
self.selectedDate = cell.cellId
}
return cell
}
Related
I have In the same view controller a calendarTableview that represent a month and a timeSlotCollectionView that represent the current day opening time divided in 30 min slots. My intent is that at loading the view controller inside calendarTableview cellForRowAt I check if it's current day and set it as selected, and load the timeSlotCollectionViewwith again a certain criteria. It all works es expected only when I physically select the row, triggering didSelectRowAtbut not on first load. All the updating is done by a function that I call in both cellForRowAtand didSelectRowAt, but on load is not updating timeSlotCollectionView. I had a similar problem in the next stage of my app, when you actually select a time slot and with my previous question has been solved, but I can't apply that in this scenario. Can you see where I'm mistaking this time?
The functions are:
for calendarTableView
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "calendarCell", for: indexPath) as! CalendarTableViewCell
// Configure the cell...
let date = datesArray[indexPath.row]
print(date)
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day, .weekday], from: date)
cell.dayLabel.text = "\(String(describing: components.day!))" + " " + "\(dayNamesArray[components.weekday! - 1])"
cell.cellWeekday = components.weekday!
print("cell weekday is: \(cell.cellWeekday!)") // prints correct weekday
cell.cellId = "\(String(format:"%04d", components.year!))" + "\(String(format:"%02d", components.month!))" + "\(String(format:"%02d", components.day!))"
self.selectedDate = cell.cellId // used for time slots cellId
// highlighting current day cell
if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
cell.dayLabel.backgroundColor = UIColor.red.withAlphaComponent(0.3)
// emulate user selecting the cell
tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableViewScrollPosition.none) // changing to .middle makes the tableview go looping
print(" ########################## selected cell weekday is: \(cell.cellWeekday!) #################### ")
self.updateTimeSlots(selectedCell: cell)
// self.actualWeekday = cell.cellWeekday!
// self.selectedDate = cell.cellId
// calculateOpenTimeSlots()
}
let cornerRadius: CGFloat = 5
cell.layer.cornerRadius = cornerRadius
cell.clipsToBounds = true
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath) as! CalendarTableViewCell
self.updateTimeSlots(selectedCell: cell)
// self.actualWeekday = cell.cellWeekday!
// self.selectedDate = cell.cellId
// print(" selected cell weekday is: \(cell.cellWeekday!)")
// calculateOpenTimeSlots()
}
for timeSlotCollectionView:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "timeSlotCell", for: indexPath) as! TimeSlotCollectionViewCell
// let booking = self.fetchedResultController.object(at: indexPath)
// Configure the cell
cell.timeLabel.text = timeSlotArray[indexPath.row]
cell.cellId = Int64("\(String(describing: self.selectedDate))" + self.timeStringToStringConvert(timeSlotArray[indexPath.row]))!
// method two USING fetchResultController
if (self.fetchedResultController.fetchedObjects?.count)! > 0 {
for value in self.fetchedResultController.fetchedObjects! {
if Int64(value.bookingId!) == cell.cellId {
print(" match found")
print("Index is: \(index)")
print("cell time is: \(timeSlotArray[indexPath.row])")
print("time slot cell id is: \(String(describing: cell.cellId))")
print("booking id: \(bookingId)")
// cell.backgroundColor = UIColor.red.withAlphaComponent(0.8)
cell.bookingState.backgroundColor = UIColor.red.withAlphaComponent(0.8)
}
}
}
print(" cell.cellId is : \(String(describing: cell.cellId!))")
print(" #################################### time slot created ################################ ")
// Method one : USING ARRAY works in realtime
// if bookedTimeSlotsArray.count > 0 {
// for index in 0...bookedTimeSlotsArray.count - 1 {
// let bookingId = bookedTimeSlotsArray[index].bookingId
//
// if cell.cellId == bookingId {
// print(" match found")
// print("Index is: \(index)")
// print("cell time is: \(timeSlotArray[indexPath.row])")
// print("time slot cell id is: \(String(describing: cell.cellId))")
// print("booking id: \(bookingId)")
//// cell.backgroundColor = UIColor.red.withAlphaComponent(0.8)
// cell.bookingState.backgroundColor = UIColor.red.withAlphaComponent(0.8)
// }
// }
// }
return cell
}
and the values updating :
func updateTimeSlots(selectedCell: CalendarTableViewCell) {
self.actualWeekday = selectedCell.cellWeekday!
self.selectedDate = selectedCell.cellId
print(" selected cell weekday is: \(selectedCell.cellWeekday!)")
fetchBookings()
calculateOpenTimeSlots()
}
Can it be a time lag between the cells creation of the two? In my other question this was the case. Many thanks as always.
I found what the problem was. I was refreshing timeSlotCollectionViewin a function that calculated the booked time slots. I guess that there was I little time gap between the array being populated from that function and timeSlotCollectionViewreading from that array to draw its cells, resulting in plain cells. I modified cellForItemAt so I can perform the check for condition directly from fetched results and that way I could bypass that function. Now the correct cell in calendarTableView gets selected and timeSlotCollectionViewgets populated with correct cells.
I hope that this could help others facing the same problem.
This is the new function:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "timeSlotCell", for: indexPath) as! TimeSlotCollectionViewCell
// let booking = self.fetchedResultController.object(at: indexPath)
// Configure the cell
cell.timeLabel.text = timeSlotArray[indexPath.row]
cell.cellTime = timeSlotArray[indexPath.row]
cell.cellId = Int64("\(String(describing: self.selectedDate))" + self.timeStringToStringConvert(timeSlotArray[indexPath.row]))!
// method two USING fetchResultController
if (self.fetchedResultController.fetchedObjects?.count)! > 0 {
for valueStart in self.fetchedResultController.fetchedObjects! {
// booking start match
if timeStringToStringConvert(cell.cellTime) == timeStringToStringConvert(valueStart.bookingStart!) {//} && cell.cellTime <= timeStringToStringConvert(valueStart.bookingEnd!) {
print(" match found")
// print("Index is: \(index)")
print("cell time is: \(timeSlotArray[indexPath.row])")
print("time slot cell id is: \(String(describing: cell.cellId))")
print("booking id: \(valueStart.bookingId!)")
// cell.backgroundColor = UIColor.red.withAlphaComponent(0.8)
cell.bookingState.backgroundColor = UIColor.red.withAlphaComponent(0.8)
cell.backgroundColor = UIColor.red.withAlphaComponent(0.25)
}
else if timeStringToStringConvert(cell.cellTime) > timeStringToStringConvert(valueStart.bookingStart!) && timeStringToStringConvert(cell.cellTime) < timeStringToStringConvert(valueStart.bookingEnd!){
print(" Mid slot found")
print(" mid slot id is: \(String(describing: cell.cellId))")
cell.bookingState.backgroundColor = UIColor.red.withAlphaComponent(0.3)
cell.backgroundColor = UIColor.red.withAlphaComponent(0.15)
cell.isUserInteractionEnabled = false
}
print("bookingId is: \(valueStart.bookingId!)")
}
}
I am stuck at this for a while now, and while I think I know what is the issue I am still not able to solve it. I am working with tableView with each cell having countdown bar animation. Each cell has a custom time duration set by the user. Then a bar animation slides as the time elapses.
I am using CADisplayLink to get this animation running, this code is written in controller file and I am just changing the width of a UIView as the time elapses:
#objc func handleProgressAnimation() {
let currenttime = Date()
let elapsed = currenttime.timeIntervalSince(animationStartDate)
let totalWidth: Double = 400.0
print(elapsed)
let arrayLength = durationBar.count
var i: Int = 0
for _ in 0..<arrayLength {
let indexPath = IndexPath(row: i, section: 0)
let percentage = (elapsed / Double(durationBar[i].durationTime))
let newWidth = Double(totalWidth - (totalWidth * percentage))
durationBar[i].width = newWidth
if (percentage < 1)
{
if let cell = listTableView.cellForRow(at: indexPath) as! listTableViewCell? {
cell.timeRemainingView.frame.size.width = CGFloat(durationBar[indexPath.row].width)
}
}
else {
if let cell = listTableView.cellForRow(at: indexPath) as! listTableViewCell? {
cell.timeRemainingView.frame.size.width = 400
cell.timeRemainingView.isHidden = true
}
}
i = i + 1
}
}
When all the bars are decreasing, everything goes fine but as one of the cells time is completed then the UIView width becomes zero and then as the user scrolls that cell is reused and this vanishes the progress bar from other cells where there is still time.
I am using prepareforsegue() method to reset the width of the bar to 400(default value) but that doesn't seem to work.
This is cellforRow code:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellid, for: indexPath) as! listTableViewCell
cell.testlabel.text = "\(duration[indexPath.row].durationTime)"
cell.timeRemainingView.frame.size.width = CGFloat(durationBar[indexPath.row].width)
return cell
}
And this is PrepareForReuse()
override func prepareForReuse() {
super.prepareForReuse()
self.timeRemainingView.frame.size.width = 400
self.timeRemainingView.isHidden = false
}
Here is a screenshot. You can see in some cells the time is up, but in others there is still time remaining but the progress bar has disappeared.
You have to set the frame again. width is a get-only property.
Image Depicting One tableViewCell. Inside One tableViewCell there is some content and One CollectionView(Gray color area showing dates).
Depending on dates in collection view and their scrolling I have to show Year and Month("December 2018" : It is static in image).
This is my JTAppleCalender cellForItemAt method :
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CalenderCell", for: indexPath) as! CalenderCell
cell.lblDate.text = cellState.text
formatter.dateFormat = "EEE"
cell.lblDay.text = formatter.string(from: cellState.date)
formatter.dateFormat = "MMMM YYYY"
print(formatter.string(from: cellState.date))
formatter.dateFormat = "dd-MM-yyyy"
print(formatter.string(from: cellState.date))
if(pickup_dates .contains(formatter.string(from: cellState.date))){
let index = pickup_dates.index(of: formatter.string(from: cellState.date))
let dictinfoDelivery = self.infoDelivery.object(at: index) as! NSDictionary
cell.lblPrice.text = dictinfoDelivery .value(forKey: "total_price_format") as? String
cell.isUserInteractionEnabled = true
}
else{
cell.lblPrice.text = ""
cell.isUserInteractionEnabled = false
}
return cell
}
I am trying to access tableView label("December 2018") from inside of this method but was unable to do so.
How to access this TableViewCell label from child collectionViewCell?
My Requirement is to Change 2-3 contents in tableViewCell (Price,quantity) wrt Date Selected in Child CollectionView.
please try this
guard let lbl = (self.yourTableView.cellForRow(at: [NSIndexPath(row: 0, section: 0) as IndexPath]) as! yourCellNameInTableView).labelName else {
return
}
lbl.text = "Your text"
Please pass your row number and section number. It may helps to you.Thanks you
I' m working to an e-commerce app and I have an issue when trying to set the height of a specific row. When I choose the category the table reloads and depending on the category i choosed more or less rows are coming through the api.
So with this setup it s working when i select a specific category but when i choose another it will mess my rows and will increase the height to another
let firstCellHeight:CGFloat = 265
let addBtnCellHeight:CGFloat = 60
let phoneCellHeight: CGFloat = 95
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let cellIdentifier = self.tableCells[indexPath.row]
let height:CGFloat!
switch cellIdentifier {
case "AddAdImagesCell":
height = self.firstCellHeight
case "AddBtnCell":
height = self.addBtnCellHeight
case "ExtraFieldCell":
if indexPath.row == 4 {
height = self.phoneCellHeight
} else {
height = 44
}
default:
height = 44
}
return height
}
For the cell for row i m having this code:
case "ExtraFieldCell":
let currentField = self.extraFields[indexPath.row - self.firstExtraFieldIndex]
switch currentField.type {
case "select":
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldSelectCell")!
if currentField.name == "area"
return cell
case "text":
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldTextCell") as! FiltersTFCell
cell.label.text = "\(currentField.label):"
return cell
case "checkbox":
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldCheckboxCell") as! CheckboxCell
cell.fieldLabel.text = currentField.label
return cell
default:
let cell = UITableViewCell()
return cell
}
So how to set the height 95 always for the row with the case "text"
try using self.tableView.rowHeight when setting the cell, I tried to apply with your example code below, if you have any questions call me back.
case "ExtraFieldCell":
let currentField = self.extraFields[indexPath.row - self.firstExtraFieldIndex]
switch currentField.type {
case "select":
self.tableView.rowHeight = firstCellHeight
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldSelectCell")!
if currentField.name == "area"
return cell
case "text":
self.tableView.rowHeight = addBtnCellHeight
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldTextCell") as! FiltersTFCell
cell.label.text = "\(currentField.label):"
return cell
case "checkbox":
self.tableView.rowHeight = phoneCellHeight
let cell = tableView.dequeueReusableCell(withIdentifier: "ExtraFieldCheckboxCell") as! CheckboxCell
cell.fieldLabel.text = currentField.label
return cell
default:
self.tableView.rowHeight = 44
let cell = UITableViewCell()
return cell
}
importantly, when is test comment or remove this method
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { ... }
I have problem liked this:
I have some row, when i click row 0, it expanded and dropdown image rotate. when i click row 1, it expand row 1 and unexpand row 0, dropdown image in row 0 back to normal (down arrow), and dropdown image in row 1 rotate (up arrow).
Here is my code so far:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = self.tableView.cellForRow(at: indexPath) as! PaymentMethodCell
let clickedRow = indexPath.row
if indexPath.row == selectedRow{
print("yang muncul selectedRow = -1")
if cell.isSelected {
selectedRow = -1
print("This cell is deselected :\(selectedRow)")
cell.ivExpand.transform = CGAffineTransform(rotationAngle: (180.0 * CGFloat.pi) * 180.0)
}else{
selectedRow = indexPath.row
cell.ivExpand.transform = CGAffineTransform(rotationAngle: (180.0 * CGFloat.pi) / 180.0)
}
}else{
if cell.isSelected {
selectedRow = indexPath.row
print("This cell is selected :\(selectedRow)")
cell.ivExpand.transform = CGAffineTransform(rotationAngle: (180.0 * CGFloat.pi) / 180.0)
}else{
selectedRow = -1
cell.ivExpand.transform = CGAffineTransform(rotationAngle: (180.0 * CGFloat.pi) * 180.0)
}
cell.lblclickedsubcell.text="00"
print("cell.lblclickedsubcell.text:\(String(describing: cell.lblclickedsubcell.text!))")
}
tableView.reloadData()
}
but the result is after i expand row 0 and then click row 1, row 0 unexpand and row 1 expanded. But dropdown image in row 0 still not back to normal (down arrow). it still as up arrow.
Here is cellForRowAt :
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "PaymentMethodCell", for: indexPath) as! PaymentMethodCell
cell.ivPaymentMeyhod.contentMode = UIViewContentMode.scaleAspectFit
cell.ivPaymentMeyhod.contentMode = UIViewContentMode.left
cell.ivPaymentMeyhod.clipsToBounds=false
//cell.ivPaymentMeyhod.kf.setImage(with: url!)
cell.ivPaymentMeyhod.image = UIImage(named: "\(PaymentImageArray[indexPath.item])")
let clickedRow = indexPath.row
cell.lblclickedRow.text = "\(indexPath.row)"
let ContractNumber = "\(contractnumber!)"
if(CustomUserDefaults.shared.isGuest() || ContractNumber==""){
cell.lblContractNumber.text = ""
cell.lblContractAmount.text = ""
}else{
cell.lblContractNumber.text = "\(contractnumber!)"
cell.lblContractAmount.text = "\(contractamount!)"
}
if(clickedRow==0){
cell.tableView.isHidden=true
cell.XibView.isHidden=false
let AlfaIndoView = HowToPayView.AlfaIndoNib()
let cellwidth = cell.XibView.bounds.width
print("cellwidth:\(cellwidth)")
cell.XibView.addSubview(AlfaIndoView)
AlfaIndoView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
AlfaIndoView.frame.size.width = cellwidth
}else if(clickedRow==1){
cell.tableView.isHidden=true
cell.XibView.isHidden=false
let POSindonesiaView = HowToPayView.POSindonesiaNib()
let cellwidth = cell.XibView.bounds.width
print("cellwidth:\(cellwidth)")
cell.XibView.addSubview(POSindonesiaView)
POSindonesiaView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
POSindonesiaView.frame.size.width = cellwidth
}else if(clickedRow==2){
cell.tableView.isHidden=false
cell.XibView.isHidden=true
cell.setUpTable()
}else if(clickedRow==3){
cell.tableView.isHidden=false
cell.XibView.isHidden=true
cell.setUpTable()
}else if(clickedRow==4){
cell.tableView.isHidden=false
cell.XibView.isHidden=true
cell.setUpTable()
}else if(clickedRow==5){
cell.tableView.isHidden=false
cell.XibView.isHidden=true
cell.setUpTable()
}else if(clickedRow==6){
cell.tableView.isHidden=true
cell.XibView.isHidden=false
let ATMbersamaView = HowToPayView.ATMbersamaNib()
let cellwidth = cell.XibView.bounds.width
print("cellwidth:\(cellwidth)")
cell.XibView.addSubview(ATMbersamaView)
ATMbersamaView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
ATMbersamaView.frame.size.width = cellwidth
}
return cell
}
Help me, please to repair this code
It would be clearer if we could see your cellForRow code. As far as I can see, you are calling reloadData() at the end, so your cells are getting re-rendered, so you have to handle the arrow's orientations in your cellForRow code. So in pseudocode form, it would be a bit like the following:
In didSelect function:
selectedIndexPath = indexPath
//...other related statements
In cellForRow function:
if indexPath == selectedIndexPath {
//rotate arrow down
//other relevant code
}
else {
//rotate arrow up
//other relevant code
}