Comments (12)
Awesome...!!
Issue resolved
Thank you very much for your time and prompt reponse :-)
from rskgrowingtextview.
@umair2ooo Probably, you need to reload your input accessory view. Try textView.reloadInputViews()
.
from rskgrowingtextview.
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.
@umair2ooo If you provide a test project with your problem, maybe I can help you.
from rskgrowingtextview.
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.
I tried to reloadinputViews in "textViewDidChange"
but no luck
this is UICollectionViewController
from rskgrowingtextview.
@umair2ooo Could you provide a test project, not a part of code?
from rskgrowingtextview.
actually test project size is greater than 10MB
I tried
let me share a link of dropbox
wait
from rskgrowingtextview.
https://www.dropbox.com/s/or79rxupvbra03h/CustomChatView.zip?dl=0
from rskgrowingtextview.
There is a bunch of code
just see CV_chat
from rskgrowingtextview.
@umair2ooo ok
from rskgrowingtextview.
- Use version 4.0.5 of RSKGrowingTextView in your Podfile.
pod 'RSKGrowingTextView', '4.0.5'
- Instead of setting
self.TV_growing.delegate
inviewDidLoad()
settranslatesAutoresizingMaskIntoConstraints
ofTV_growing
tofalse
.
self.TV_growing.translatesAutoresizingMaskIntoConstraints = false
Everything should work.
from rskgrowingtextview.
Related Issues (20)
- Swift 4 compiler error HOT 7
- Growing down HOT 4
- Bottom space HOT 3
- Incorrect height when setting text in viewDidLoad() HOT 3
- RSK inside UIView HOT 2
- Bug placeholder HOT 8
- IOS 13 HOT 1
- Profile.storyboard: error: IB Designables: Failed to render and update auto layout status HOT 4
- delegate method is not called HOT 2
- Bug in keyboard dismissing HOT 2
- SPM Integration error HOT 2
- Constraints break on UIPasteBoard -> paste action HOT 3
- Support TextKit2 HOT 6
- blinking black screen & textview not appearing above keyboard HOT 2
- Privacy Manifest HOT 2
- Placeholder descenders are clipped HOT 1
- How can I tigger height change programatically HOT 3
- No such module 'RSKKeyboardAnimationObserver' HOT 1
- Issue resizing the textView HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rskgrowingtextview.