Wednesday, 15 September 2010

iOS8/Swift: UICollectionViewCell height calculation -


From other posts about this subject, I tried the following approach - but in some way "fu" as well as " Bar "may be

  func collectionView (see archive: UICollectionView, Layout ViewViewLayout: UICollectionViewFlowLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) - & gt; CGSize {var foo = collectionView.cellForItemAtIndexPath (indexpath) as? MessageCell var bar = foo? .messagetext.frame.height Return to Class:  
  

CustomSheet: Code> Call the class message: UICollectionViewCell, Delegate the UIPopover Presentation Controller, UITextViewDelegate {@Iboutlet weak var AuthorLabel: UILBL! @IBOutlet Weak World Timestamp Label: UILball! @ IBOutlet weak var message text: UITextView! Func setCell (authorLabelText: string, message text: string, timestamp label text: string) {self.authorLabel? .text = authorLabelText self.timestampLabel? .text = timestampLabelText self message text? .text = messageText self.messageText.delegate = self.messageText .sizeToFit () // works, when I have a custom color background printline (auto-message.text.frame.hete)}}

I am giving a different heights to my custom cell orbit? There will be no such reason because it has not been sung yet, right?

€ dit: A screenshot from the stop at "foo": Enter image details here

bar is because Foo is zero - this is the option that "? " is doing in that expression if as the collection View.cellForItemAtIndexPath (indexPath)? The message is , which means either:

  • There is no cell on that index path, or
  • There is not an example of a MessageCell

on cell indexPath , I suggest that more likely to be later That's because those representative messages are actually 'called by an illegal index route where you register your cell class (in code or in the storyboard), are you sure However, are they MessageCell Registration as sales? <

No comments:

Post a Comment