Git Product home page Git Product logo

Comments (12)

umair2ooo avatar umair2ooo commented on June 1, 2024 1

Awesome...!!
Issue resolved
Thank you very much for your time and prompt reponse :-)

from rskgrowingtextview.

ruslanskorb avatar ruslanskorb commented on June 1, 2024

@umair2ooo Probably, you need to reload your input accessory view. Try textView.reloadInputViews().

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

When should I reload ?
I will be thankful to you if you give a demo code or guide me how to handle it.
Thanks

from rskgrowingtextview.

ruslanskorb avatar ruslanskorb commented on June 1, 2024

@umair2ooo If you provide a test project with your problem, maybe I can help you.

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

import UIKit
import RSKGrowingTextView

private let reuseIdentifier = "Cell"

class CV_chat: UICollectionViewController {

@IBOutlet weak var TV_growing: RSKGrowingTextView!

private let messages = ["asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df UMAIR \n\n\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas",
                        "asd fas df asdf asd f asdf asd f as",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df as\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df UMAIR \n\n\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas",
                        "asd fas df asdf asd f asdf asd f as",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df as\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df UMAIR \n\n\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas",
                        "asd fas df asdf asd f asdf asd f as",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df as\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df UMAIR \n\n\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf",
                        "asd fas",
                        "asd fas df asdf asd f asdf asd f as",
                        "asd fas df asdf asd f asdf asd f asdf as df asdf asd fa sdf adsf as df asd fas df as\na sdf asd fas fa sdf asdf asd fa sdf asdf asf as df sadf asdf asd \n asf as fasd fa sdf asdf asd f asf adsf"]






override func viewDidLoad() {
    super.viewDidLoad()
    
    self.TV_growing.delegate = self
}



override var inputAccessoryView: UIView? {
    get {
        return self.TV_growing
    }
}

override var canBecomeFirstResponder: Bool {
    return true
}




// MARK: UICollectionViewDataSource
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return 1
}

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    
    if indexPath.section < 3 {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: CollCellText.self), for: indexPath) as! CollCellText
        cell.lbl_text.text = self.messages[indexPath.section]
        return cell
    }
    else if indexPath.section >= 3 && indexPath.section <= 6 {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: CollCellText.self), for: indexPath) as! CollCellText
        cell.lbl_text.text = self.messages[indexPath.section]
        return cell
    }
    else {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: CollCellText.self), for: indexPath) as! CollCellText
        cell.lbl_text.text = self.messages[indexPath.section]
        return cell
    }
}



override func numberOfSections(in collectionView: UICollectionView) -> Int {
    return self.messages.count
}

}

//MARK:- UICollectionViewDelegateFlowLayout
extension CV_chat : UICollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    
    let yourWidthOfLable = ((collectionView.frame.size.width * 74.0641)/100)
    let font = UIFont(name: "Helvetica", size: 17.0)
    
    let expectedHeight = self.heightForLable(text: self.messages[indexPath.section], font: font!, width:yourWidthOfLable )+32 // 32 is padding          16 -- Label -- 16
    
    return CGSize(width: view.frame.width, height: expectedHeight)
}

}

extension CV_chat {
func heightForLable(text:String, font:UIFont, width:CGFloat) -> CGFloat{
// pass string ,font , LableWidth
let label:UILabel = UILabel(frame: CGRect(x: 0, y: 0, width: width, height: CGFloat.greatestFiniteMagnitude))
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakMode.byWordWrapping
label.font = font
label.text = text
label.sizeToFit()

    return label.frame.height
}

}

extension CV_chat: UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {

    if textView.text.contains("\n") {
        self.TV_growing.reloadInputViews()
    }
}

}

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

I tried to reloadinputViews in "textViewDidChange"
but no luck
this is UICollectionViewController
screen shot 2019-02-08 at 10 20 46 am

from rskgrowingtextview.

ruslanskorb avatar ruslanskorb commented on June 1, 2024

@umair2ooo Could you provide a test project, not a part of code?

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

actually test project size is greater than 10MB
I tried
let me share a link of dropbox
wait

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

https://www.dropbox.com/s/or79rxupvbra03h/CustomChatView.zip?dl=0

from rskgrowingtextview.

umair2ooo avatar umair2ooo commented on June 1, 2024

There is a bunch of code
just see CV_chat

from rskgrowingtextview.

ruslanskorb avatar ruslanskorb commented on June 1, 2024

@umair2ooo ok

from rskgrowingtextview.

ruslanskorb avatar ruslanskorb commented on June 1, 2024
  1. Use version 4.0.5 of RSKGrowingTextView in your Podfile.
pod 'RSKGrowingTextView', '4.0.5'
  1. Instead of setting self.TV_growing.delegate in viewDidLoad() set translatesAutoresizingMaskIntoConstraints of TV_growing to false.
self.TV_growing.translatesAutoresizingMaskIntoConstraints = false

Everything should work.

from rskgrowingtextview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.