मैं कोशिकाओं का विस्तार और पतन करने में सक्षम हूं लेकिन मैं बटन शीर्षक बदलने के लिए UITableViewCell के अंदर फ़ंक्शन (विस्तार और पतन) कॉल करना चाहता हूं।तालिकादृश्य कक्षों का विस्तार और संकुचित करें
import UIKit class MyTicketsTableViewController: UITableViewController { var selectedIndexPath: NSIndexPath? var extraHeight: CGFloat = 100 override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! MyTicketsTableViewCell return cell } override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { if(selectedIndexPath != nil && indexPath.compare(selectedIndexPath!) == NSComparisonResult.OrderedSame) { return 230 + extraHeight } return 230.0 } override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if(selectedIndexPath == indexPath) { selectedIndexPath = nil } else { selectedIndexPath = indexPath } tableView.beginUpdates() tableView.endUpdates() } }
import UIKit class MyTicketsTableViewCell: UITableViewCell { @IBOutlet weak var expandButton: ExpandButton! @IBOutlet weak var detailsHeightConstraint: NSLayoutConstraint! var defaultHeight: CGFloat! override func awakeFromNib() { super.awakeFromNib() defaultHeight = detailsHeightConstraint.constant expandButton.button.setTitle("TAP FOR DETAILS", forState: .Normal) detailsHeightConstraint.constant = 30 } func expand() { UIView.animateWithDuration(0.3, delay: 0.0, options: .CurveLinear, animations: { self.expandButton.arrowImage.transform = CGAffineTransformMakeRotation(CGFloat(M_PI * 0.99)) self.detailsHeightConstraint.constant = self.defaultHeight self.layoutIfNeeded() }, completion: { finished in self.expandButton.button.setTitle("CLOSE", forState: .Normal) }) } func collapse() { UIView.animateWithDuration(0.3, delay: 0.0, options: .CurveLinear, animations: { self.expandButton.arrowImage.transform = CGAffineTransformMakeRotation(CGFloat(M_PI * 0.0)) self.detailsHeightConstraint.constant = CGFloat(30.0) self.layoutIfNeeded() }, completion: { finished in self.expandButton.button.setTitle("TAP FOR DETAILS", forState: .Normal) }) } }
इस समाधान की जाँच करें: (https://stackoverflow.com/questions/21396907/how-to-programmatically-increase-uitableview-cells-height-in-iphone/45424594# [कड़ी यहाँ विवरण दर्ज] 45424594) –