Posts

Showing posts with the label uitableview

Rounding the height of a table cell in Swift

Rounding the height of a table cell in Swift I need to calculate the cell height of the table and round it to a divisible value by 5. For example, when the cell size is 116, the correct height should be 120. The point is that I use the adaptive layout to calculate the cell height. One of the subviews of UITableViewCell is a vertical dashed line which should connect to cell below. The dashed line consists of repeating of 5 points - dash (2 points) and gap (3 points). So the height of line view should be rounded up to the value divisible by 5 for correct connection with dashed line of cell wich is below. Two cells with connected dashed line Show your tried code? – Pratik Prajapati Jun 30 at 11:28 somebody has marked the question as duplicated without understanding the problem - never mind ... – ...

Content Scroll to Row at Index Path beyond bonds?

Content Scroll to Row at Index Path beyond bonds? So I was able to have the annotation's callout animate when the selected table cell was selected like so. Quite simple due to the indexPath. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let indexPath = indexPath.row myMap.selectAnnotation(pinArray[indexPath] , animated: true) } However, I do not understand how to achieve this when I select the annotation and want the table cell to light up. I've been attempting to set a var to indexPath but because the annotation has no subscript, I am unable to perform this. Therefore, how would I be able to accomplish the annotation to selected cell logic? func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { //Magic } Update - currently the code I have to highlight the table cell correlated to the map annotation is this. func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { let index = pinArray.index(of: ...

Identify in which table view Cell button was pressed?

Image
Identify in which table view Cell button was pressed? I have table view cells like quiz. And in each cell I have a buttons And how can I identify in which cell button was pressed. Maybe by IndexPath??? This is how I connected button to func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "QuestionCell")! variant1 = cell.contentView.viewWithTag(1) as! UIButton variant2 = cell.contentView.viewWithTag(2) as! UIButton variant3 = cell.contentView.viewWithTag(3) as! UIButton variant4 = cell.contentView.viewWithTag(4) as! UIButton variant1.addTarget(self, action: #selector(self.variant1ButtonPressed), for: .touchUpInside) variant2.addTarget(self, action: #selector(self.variant2ButtonPressed), for: .touchUpInside) variant3.addTarget(self, action: #selector(self.variant3ButtonPressed), for: .touchUpInside) variant4.addTarget(self, action: #sel...