1

I'm building a custom keyboard, I'm trying to recreate the iOS emoji keyboard. So I created a UICollectionView and each cell contains an emoji (UILabel).

But it's not scrolling smoothy. I don't know if it comes from the UICollectionView of something else.

  • Emojis are in a plist file, I open it in viewDidLoad
  • I'm using a xib cell file for my UICollectionViewCell (since there is no other way with a custom keyboard)
  • I made a test by removing the UILabel from the UICollectionViewCell and it's still not scrolling smoothy

Any clue?


EDIT

var emojis=[[String]]()

override func awakeFromNib(){
    dataSource=self
    delegate=self

    let nib=UINib(nibName: "EmojiKeyCell", bundle: nil)
    register(nib, forCellWithReuseIdentifier: cellId)
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell=collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! EmojiKeyCell
    let emoji=emojis[indexPath.section][indexPath.item]
    cell.emojiKey.text=emoji
    return cell
}
Marie Dm
  • 2,637
  • 3
  • 24
  • 43
  • Can you post your collection view code? Specifically your `cellForItem(at:)` function? – nathangitter Nov 30 '17 at 16:17
  • @nathan Just added it – Marie Dm Nov 30 '17 at 16:22
  • Try running the profiler (`Cmd + i`) to see where your bottleneck is. And add spaces before and after your assignments `dataSource = self` instead of `dataSource=self`. It will make your code easier to read. – EmilioPelaez Nov 30 '17 at 16:26
  • @nathan Actually I tried and did not succeed. I asked another question for this > https://stackoverflow.com/questions/47513051/run-xcode-instruments-on-device-with-a-ios-keyboard-extension – Marie Dm Nov 30 '17 at 16:28

0 Answers0