I have a tableview with 2 textbox.text1 loads data on viewdidload function.
for text2, the input is dates. I am using tableview didselectrow method to show datepicker. but when i select date from datepicker, it is printing in console but not added in textbox.
` override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedIndex = indexPath.row
let screenSize: CGRect = UIScreen.mainScreen().bounds
datePickerContainer.frame = CGRectMake(20, 200, 290, 200.0)
datePickerContainer.backgroundColor = UIColor.whiteColor()
datePickerContainer.layer.borderWidth = 2.0
datePickerContainer.layer.borderColor = UIColor.lightGrayColor().CGColor
var pickerSize : CGSize = datePicker.sizeThatFits(CGSizeZero)
datePicker.frame = CGRectMake(0.0, 20, pickerSize.width, 160)
//datePicker.setDate(NSDate(), animated: true)
//datePicker.maximumDate = NSDate()
datePicker.datePickerMode = .Date
datePicker.addTarget(self, action: "dateChangedInDate:", forControlEvents: UIControlEvents.ValueChanged)
datePickerContainer.addSubview(datePicker)
var doneButton = UIButton()
doneButton.setTitle("Done", forState: UIControlState.Normal)
doneButton.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
doneButton.addTarget(self, action: Selector("dismissPicker:"), forControlEvents: UIControlEvents.TouchUpInside)
doneButton.frame = CGRectMake(130.0, 160, 70.0, 37.0)
datePickerContainer.addSubview(doneButton)
self.view.addSubview(datePickerContainer)
}
func dateChangedInDate(sender:UIDatePicker){
dateFormatter.dateStyle = .ShortStyle
dateFormatter.dateFormat = "yyyy-MM-dd"
let selectedDate = dateFormatter.stringFromDate(datePicker.date)
firstIndex = NSIndexPath(forRow: selectedIndex, inSection: 0)
let cell = tableView.cellForRowAtIndexPath(firstIndex) as! mytableviewcell
cell.dateText.text = dateFormatter.stringFromDate(datePicker.date)
// print(selectedDate)
}
`
Any help is appreciated....
You should try making all updates to cells inside the tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell method. Make it so that the text of your label is bound to the DatePicker value. Then, inside your dataChangedWithDate() method, trigger a table update of the row in question using table.reloadRowsAtIndexPath(). Note that I'm assuming selectedIndex is an instance variable for your controller, so that you have access to it inside the dateChangedWithDate() method.
tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Dequeue the cell, perform all of your other tasks for laying out the cell
// {...}
// Bind the label's text to the DatePicker value
dateFormatter.dateStyle = .ShortStyle
dateFormatter.dateFormat = "yyyy-MM-dd"
cell.dateText.text = dateFormatter.stringFromDate(datePicker.date)
}
func dateChangedInDate(sender:UIDatePicker){
// Trigger table update for the selected row
let indexPath = NSIndexPath(forRow: selectedIndex, inSection:0)
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
create Variable to store data value.
// var dateTime = ""
//cellForIndexMethod
cell.dateText.text = dateTime
func dateChangedInDate(sender:UIDatePicker){
dateFormatter.dateStyle = .ShortStyle
dateFormatter.dateFormat = "yyyy-MM-dd"
dateTime = dateFormatter.stringFromDate(datePicker.date)
let indexPath = NSIndexPath(forRow: selectedIndex, inSection:0)
//Reload table
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
Related
I am unable to select future dates from the date picker view. I would like to be able to select only current and future dates, not past dates.
{
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: EnterAccountCell2.self), for: indexPath) as! EnterAccountCell2
cell.inputTextField.title = NSLocalizedString("StartDate", comment: "")
cell.inputTextField.delegate = self
cell.inputTextField?.placeholder = NSLocalizedString("PleaseSelect", comment: "")
cell.inputTextField.titleFont = UIFont(name: UIConfiguration.getUIFONTAPP(), size: UIConfiguration.kFontSizeMedium)!
cell.inputTextField.tag = 222
cell.inputTextField.inputView = UIView(frame: .zero)
cell.inputTextField.text = self.myDateShow
cell.datePickerView.addTarget(self, action: #selector(datePickerChanged(picker:)), for: .valueChanged)
cell.selectView.isHidden = false
cell.inputTextField.isUserInteractionEnabled = true
cell.datePickerView.minimumDate = Date()
cell.datePickerView.maximumDate = Date(timeInterval: 10976*24*60*60, since: Date())
return cell
}
To limit the date picker view to only display current and future dates, you need to set the minimumDate property of the datePickerView to the current date. In the code you provided, this is done with the following line:
cell.datePickerView.minimumDate = Date()
Example:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: EnterAccountCell2.self), for: indexPath) as! EnterAccountCell2
cell.inputTextField.title = NSLocalizedString("StartDate", comment: "")
cell.inputTextField.delegate = self
cell.inputTextField?.placeholder = NSLocalizedString("PleaseSelect", comment: "")
cell.inputTextField.titleFont = UIFont(name: UIConfiguration.getUIFONTAPP(), size: UIConfiguration.kFontSizeMedium)!
cell.inputTextField.tag = 222
cell.inputTextField.inputView = UIView(frame: .zero)
cell.inputTextField.text = self.myDateShow
cell.datePickerView.addTarget(self, action: #selector(datePickerChanged(picker:)), for: .valueChanged)
cell.selectView.isHidden = false
cell.inputTextField.isUserInteractionEnabled = true
cell.datePickerView.minimumDate = Date()
cell.datePickerView.maximumDate = Date(timeInterval: 10976*24*60*60, since: Date())
return cell
}
I have a collectionView that I am making a timeline of sorts out of. There are many thin cells in a horizontal collectionView - each cell represents 1 day. Here is the project code: https://github.com/AlexMarshall12/singleDayTimeline.git
Here is the viewController:
let cellIdentifier = "DayCollectionViewCell"
class ViewController: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate {
#IBOutlet weak var button: UIButton!
var dates = [Date?]()
var startDate: Date?
var endDate: Date?
private var selectedIndexPath: IndexPath?
#IBOutlet weak var daysCollectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
daysCollectionView.register(UINib.init(nibName: "DayCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: cellIdentifier)
let allDates = Helper.generateRandomDate(daysBack: 900, numberOf: 10)
self.dates = allDates.sorted(by: {
$0!.compare($1!) == .orderedAscending
})
self.startDate = Calendar.current.startOfDay(for: dates.first as! Date)
self.endDate = dates.last!
self.dates = Array(dates.prefix(upTo: 1))
daysCollectionView.delegate = self
daysCollectionView.dataSource = self
}
var onceOnly = false
internal func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if !onceOnly {
//let lastDateIndexPath = IndexPath(row: dates.count - 1,section: 0)
let lastDate = dates.last
let lastDayIndex = lastDate!?.interval(ofComponent: .day, fromDate: startDate!)
let lastDayCellIndexPath = IndexPath(row: lastDayIndex!, section: 0)
self.daysCollectionView.scrollToItem(at: lastDayCellIndexPath, at: .left, animated: false)
self.selectedIndexPath = lastDayCellIndexPath
self.daysCollectionView.reloadItems(at: [lastDayCellIndexPath])
onceOnly = true
}
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let days = self.endDate!.days(from: self.startDate!)
if days <= 150 {
return 150
} else {
print(days,"days")
return days + 1
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = daysCollectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! DayCollectionViewCell
let cellDate = Calendar.current.date(byAdding: .day, value: indexPath.item, to: self.startDate!)
if let selectedRow = selectedIndexPath {
cell.reloadCell(selectedRow==indexPath)
} else {
cell.reloadCell(false)
}
if Calendar.current.component(.day, from: cellDate!) == 15 {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM"
let monthString = dateFormatter.string(from: cellDate!)
cell.drawMonth(month: monthString)
}
if Calendar.current.component(.day, from: cellDate!) == 1 && Calendar.current.component(.month, from: cellDate!) == 1 {
print("drawYEAR")
cell.drawYear(year:Calendar.current.component(.year, from: cellDate!))
}
if self.dates.contains(where: { Calendar.current.isDate(cellDate!, inSameDayAs: $0!) }) {
print("same")
cell.backgroundColor = UIColor.red
}
//cell.backgroundColor = UIColor.blue
return cell
}
#IBAction func buttonPressed(_ sender: Any) {
let randomIndex = Int(arc4random_uniform(UInt32(self.dates.count)))
let randomDate = self.dates[randomIndex]
let daysFrom = randomDate?.days(from: self.startDate!)
let indexPath = IndexPath(row: daysFrom!, section: 0)
self.selectedIndexPath = indexPath;
//daysCollectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally)
daysCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
daysCollectionView.reloadData()
}
}
Note that when the buttonPressed function is Called, the "selectedIndexPath" changes. Then the next time cellForItemAt is called, it does cell.reloadCell and if the indexPath is this selectedIndexPath, it unhides the arrowImageView (see below)
class DayCollectionViewCell: UICollectionViewCell {
...
func reloadCell(_ isSelected:Bool){
arrowImage.isHidden = !isSelected
}
}
This works when the button is pressed, however I am trying to make it work in the willDisplayCell callback. You can see that in this callback I basically just get the latest (most recent) date and scroll to it and then set SelectedIndexPath to that indexPath. Now I need a way to make the arrow draw on that cell.
Here is what it looks like now:
As you can see it doesn't show the arrow UNTIL you scroll around. I think what is happening is that when you scroll around enough cellForItemAt gets called which we know works. But How do I get willDisplayCell to do the same thing successfully and thus have the arrow load from initial startup?
In your viewDidLoad, you seem to be initializing dates, startDate and endDate.
So, right after those variables are set up, you can set the selectedIndexPath using the available data. Then, when the cellForItem method is called, the code there would automatically handle the visibility of your arrow.
Place this code right after you initialize the 3 variables, inside viewDidLoad.
if let startDate = startDate,
let lastDayIndex = dates?.last?.interval(ofComponent: .day, fromDate: startDate) {
selectedIndexPath = IndexPath(row: lastDayIndex, section: 0)
}
You would not need to handle this in willDisplayCell, or use the onceOnly boolean.
I add a new answer is because I noticed some incomplete details about the other answers.
In the viewDidLoad , there is a weird code:
self.dates = Array(dates.prefix(upTo: 1))
I think this is a test code. So the result would be only one bar totally. And whatever the reason is, those codes for random one or last one should be added after this code.
let randomIndex = Int(arc4random_uniform(UInt32(self.dates.count)))
let randomDate = self.dates[randomIndex]
let daysFrom = randomDate?.days(from: self.startDate!)
let indexPath = IndexPath(row: daysFrom!, section: 0)
self.selectedIndexPath = indexPath;
// daysCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
Please notice I comment the last one. If there is only one bar, it is good enough, but if there is more than one, the scrollToItem should be added somewhere else, because currently the collectionView has not been initialized.
One idea place is just as original post in the willDisplay, Which is easy to implement. The only issue is the time span of willDisplay is short, so reloading whole collectionData cannot be called there.
But it is good for scrolling to one indexPath there. Just as the following code.
var onceOnly = false
internal func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if (!onceOnly){
self.daysCollectionView.scrollToItem(at: self.selectedIndexPath!, at: .left, animated: false)
onceOnly = true
}
}
There is another good place to call both functions (selectIndex and scrolling) as in the following place :
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let randomIndex = Int(arc4random_uniform(UInt32(self.dates.count)))
let randomDate = self.dates[randomIndex]
let daysFrom = randomDate?.days(from: self.startDate!)
let indexPath = IndexPath(row: daysFrom!, section: 0)
if self.selectedIndexPath != nil {
daysCollectionView.reloadItems(at: [self.selectedIndexPath!])
}
self.selectedIndexPath = indexPath;
daysCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
daysCollectionView.reloadItems(at: [indexPath])
}
Now I think it is a complete answer. Hope it is helpful.
I have a UISearchController with a separate UITableViewController as its searchResultsController.
class SearchResultsViewController: UITableViewController {
var fruits: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView(frame: .zero)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
#objc func addFruit(_ sender: UIButton) {
let point = tableView.convert(sender.bounds.origin, to: sender)
let indexPath = tableView.indexPathForRow(at: point)
print(indexPath?.row)
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruits.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = fruits[indexPath.row]
cell.selectionStyle = .none
let addButton = UIButton(type: .custom)
addButton.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
addButton.setImage(UIImage(named: "add"), for: .normal)
addButton.contentMode = .scaleAspectFit
addButton.addTarget(self, action: #selector(addFruit(_:)), for: .touchUpInside)
addButton.sizeToFit()
cell.accessoryView = addButton
return cell
}
}
I need to show a custom button in cells that search results are shown. So I added a UIButton as the cells' accessoryView. And it looks and works fine.
Now I need to get the cell's indexPath when the user taps on this button.
I'm trying to get it like shown below.
#objc func addFruit(_ sender: UIButton) {
let point = tableView.convert(sender.bounds.origin, to: sender)
let indexPath = tableView.indexPathForRow(at: point)
}
But it keeps returning nil for every cell.
Is there any other way to get the indexPath from a custom button tap? I added a demo project here as well.
Create a custom class named SOButton and add variable of type IndexPath to it. Use this class for your add button initialisation.
//Your class will look like -
class SOButton: UIButton {
var indexPath: IndexPath?
}
//Your action will look like -
#objc func addFruit(_ sender: SOButton) {
print(sender?.indexPath.row)
}
//And in your cellForRow add
let addButton = SOButton(type: .custom)
addButton.indexPath = indexPath
Hope this helps you :)
Please update your code. you pass the UIButton sender in convert function , please pass the tableView into them
func getIndexPathByCgPoint(_ sender: UIButton) -> IndexPath? {
let point = sender.convert(sender.bounds.origin, to: tableview)
guard let indexPath = tableview.indexPathForRow(at: point) else {
return nil
}
return indexPath
}
But in case of section header it return nil.
let buttonPosition = sender.convert(CGPoint.zero, to: self.tableView)
let currentIndexPath = self.tableView.indexPathForRow(at: buttonPosition)
Try this it worked for me :)
I would suggest using this light solution: add indexPath.row to button tag:
let addButton = UIButton(type: .custom)
addButton.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
addButton.tag = indexPath.row
And in button action:
#objc func addFruit(_ sender: UIButton) {
print(sender.tag)
}
My code:
class HomeViewController: UITableViewController {
var segmentedControl: HMSegmentedControl!
var text = [
// 名词
["音读名词","训读名词","音读与训读的分辨方法"],
// 形容词
["如何分辨形容词", "常用形容词", "形容词的变形规则"]
]
override func viewDidLoad() {
super.viewDidLoad()
configForSegmentedControl()
}
func configForSegmentedControl() {
segmentedControl = HMSegmentedControl(sectionTitles: ["名词","形容词","形容动词","片假名单词","动词","复合动词"])
segmentedControl.frame = CGRectMake(0, 0, self.view.bounds.width, 44)
segmentedControl.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10)
segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe
segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown
segmentedControl.addTarget(self, action: #selector(HomeViewController.segmentedControlChangedValue(_:)), forControlEvents: UIControlEvents.ValueChanged)
if let font = UIFont(name: "BigYoungMediumGB2.0", size: 15) {
segmentedControl.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor(), NSFontAttributeName: font]
}
segmentedControl.backgroundColor = UIColor.whiteColor()
segmentedControl.selectionIndicatorHeight = 3
segmentedControl.selectionIndicatorColor = UIColor.blackColor()
tableView.tableHeaderView = segmentedControl
}
func segmentedControlChangedValue(segmentedControl: HMSegmentedControl) {
print("Selected index \(segmentedControl.selectedSegmentIndex) (via UIControlEventValueChanged)")
}
}
extension HomeViewController {
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return text[segmentedControl.selectedSegmentIndex].count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
print("cellForRowAtIndexPath:\(segmentedControl.selectedSegmentIndex)")
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = text[segmentedControl.selectedSegmentIndex][indexPath.row]
return cell
}
}
And here is the console output:
cellForRowAtIndexPath:0
cellForRowAtIndexPath:0
cellForRowAtIndexPath:0
Selected index 1 (via UIControlEventValueChanged)
Selected index 0 (via UIControlEventValueChanged)
The cellForRowAtIndexPath gets called before the segmentedControlChangedValue which is why I can't get the correct index to get the element of text array. So what should I do?
For future reference from comment:
If you want value in cellForRow, then you should reload the tableview inside that 'segmentedControlChangedValue'
In general case to set the the cell based on the selection/action, you should reload /beginUpdates the tableview as per requirement
My table view cell is repeating when scroll while waiting to reload Data . After reload all item are reset and all repeating content are remove . Here a video showing the problem , anyone know why and how can i fixed it ? As you can see in the video the hdsdjhjdhhsdsjshhsdhsjhdjd is repeating again on the top?
https://www.dropbox.com/s/e0arcajkuuot8xa/Reflector%20Recording.mp4?dl=0
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:StatusTableCell! = tableView.dequeueReusableCellWithIdentifier("statusCell", forIndexPath: indexPath) as! StatusTableCell
if (cell == nil) {
cell.uploadDate = nil
cell.uploadStatus.text = nil
cell.statusUploader.setTitle("", forState: .Normal)
}
cell.photoImage.hidden = true
self.photoHidden = true
print("\n\n\n\n")
cell.layoutIfNeeded()
cell.likesButton.setImage(UIImage(named: "Likes"), forState: .Normal)
cell.likesButton.setTitle("0", forState: UIControlState.Normal)
print("\n\n\n\n")
//Makes The Cell Of Text View Detect Link
cell.uploadStatus.dataDetectorTypes = .Link
cell.uploadStatus.delegate = self
do {
print(date2)
cell.statusUploader.setTitle("\(user2[indexPath.row])", forState: UIControlState.Normal)
if isLoadingLikes == false {
//Modified Height Based ON Status NOTE: STILL BUGGY
cell.uploadStatus.text = status2[indexPath.row]
cell.uploadStatus.frame.size.height = textViewHeight(cell.uploadStatus)
test = cell.uploadStatus.frame.size.height
self.tableView(tableView, heightForRowAtIndexPath: indexPath)
//Likes Button Data
let uploadLikes = likes2[indexPath.row]
cell.likesButton.tag = indexPath.row
cell.likesButton.setTitle("\(uploadLikes)", forState: UIControlState.Normal)
//Add An Action Connector To Likes Button
cell.likesButton.addTarget(self, action: Selector("likesFunction:"), forControlEvents: .TouchUpInside)
cell.moreButton.addTarget(self, action: Selector("moreFunction:"), forControlEvents: .TouchUpInside)
print(liked2)
if liked2[indexPath.row] == "liked" {
cell.likesButton.setImage(UIImage(named: "Likes2"), forState: .Normal)
}else {
cell.likesButton.setImage(UIImage(named: "Likes"), forState: .Normal)
}
}
print("----------------------------- Row \(indexPath.row)")
print("Checking Date Array\(date2[indexPath.row])")
print("Check NSDATE \(NSDate().timeIntervalSinceDate(date2[indexPath.row]))")
print("Checking TIME FORMATTER \(timeAgoSinceDate(date2[indexPath.row], numericDates: true))")
print("Status = \(status2[indexPath.row])")
cell.uploadDate.text = timeAgoSinceDate(date2[indexPath.row], numericDates: true)
let stringWithNSDataDetector: String = cell.uploadStatus.text
let error: NSError? = nil
let dataDetector: NSDataDetector = try NSDataDetector(types: NSTextCheckingType.Link.rawValue)
//Check if (error) before
var allMatches: [AnyObject] = [AnyObject]()
dataDetector.enumerateMatchesInString(stringWithNSDataDetector, options: NSMatchingOptions.Anchored, range: NSMakeRange(0, stringWithNSDataDetector.characters.count), usingBlock: { (match:NSTextCheckingResult?, flags:NSMatchingFlags, pointer:UnsafeMutablePointer<ObjCBool>) -> Void in
print("Link \(match!.resultType == .Link)")
if match!.resultType == .Link {
allMatches.append(match!.URL!)
self.photoHidden = false
cell.photoImage.hidden = false
print(match!.URL!)
}
})
print("ALL Matches \(allMatches)")
print("Test \(test) -- row : \(indexPath.row)")
print(cell.uploadStatus.frame.size.height)
}
catch {
print("Error Loading Status -- (StatusTableView)")
}
print("----------------------------- End \n")
cell.setNeedsDisplay()
return cell
}
And here is another
func textViewHeight (textView:UITextView) -> CGFloat{
textView.scrollEnabled = false
let fixedWidth = textView.frame.size.width
textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
var newFrame = textView.frame
newFrame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)
textView.frame = newFrame;
return textView.frame.height
}
internal func textViewHeightForText(text: String?, andWidth width: CGFloat) -> CGFloat {
let calculationView = UITextView()
//IMPORTANT - have to specify the name/size of your font
let attributedText = NSAttributedString(string: (text != nil) ? text! : "", attributes: [NSFontAttributeName : UIFont(name: "Helvetica Neue", size: 16.0)!])
calculationView.attributedText = attributedText
let height = calculationView.sizeThatFits(CGSize(width: width, height: CGFloat.max)).height
return height
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let width = tableView.frame.size.width - 79
if photoHidden == false {
return textViewHeightForText(status2[indexPath.row], andWidth: width) + 260
}else {
return textViewHeightForText(status2[indexPath.row], andWidth: width) + 140
}
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.dequeueReusableCellWithIdentifier("statusCell", forIndexPath: indexPath) as! StatusTableCell
cell.uploadStatus.text = status2[indexPath.row]
cell.uploadStatus.frame.size.height = textViewHeight(cell.uploadStatus)
test = cell.uploadStatus.frame.size.height
self.tableView(tableView, heightForRowAtIndexPath: indexPath)
//If it is last row of the loaded table views , it will loading it got more than one current object else finish loading
if (indexPath.row == objectCount - 1) && isLoadingMoreCell == false
{
self.isLoadingMoreCell = true
self.tableView.tableFooterView = footerView
footerLoading.center.x = self.footerView.frame.width/2
footerLoading.startAnimating()
loadMoreCell()
}
}