Answer the question
In order to leave comments, you need to log in
Display collectionView bottom-up (uphill)?
The controller must display data from the bottom up, which is what it actually does. Implemented like this
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.collectionView!.transform = CGAffineTransformMake(1, 0, 0, -1, 0, 0)
takeTotalMessages()
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! ChatCollectionViewCell
cell.transform=self.collectionView!.transform
let message = dataSource[indexPath.row]
cell.nameNick?.text = message.nickname
cell.textMess?.text = message.text
return cell
}
class ChatCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var nameNick: UILabel?
@IBOutlet weak var textMess: UILabel?
}
Answer the question
In order to leave comments, you need to log in
What do you want to achieve?
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:lastRow inSection:lastSection] atScrollPosition: UICollectionViewScrollPositionBottom animated:NO];
}
First, I join the ManWithBear question , but let's play telepaths. Apparently you flipped the collectionView to add new cells to the top of the table, and they appeared at the bottom, this is an extremely bad decision.
Secondly, this `cell.transform=self.collectionView!.transform` is best done not in `cellForItemAtIndexPath ` in the `ChatCollectionViewCell` class, you just created it that way, right.
Third, make a constant `let transform = CGAffineTransformMake(1, 0, 0, -1, 0, 0)` and assign it to `self.collectionView!.transform = transform ` and `cell.transform=transform `
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question