fluidgroup / nextgrowingtextview Goto Github PK
View Code? Open in Web Editor NEW📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
License: MIT License
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
License: MIT License
Does this work in Swift 2.2/2.3? I tried 0.7.3 and linking to the commit pre-upgrade (d338070) but getting some very strange issues.
I’m working on Swift 2.3 using NextGrowingTextView 0.2.0. When I add a UIScrollView and and connect the IBOutlet, I get the error:
fatal error: unexpectedly found nil while unwrapping an Optional value
What I tried to do next is to add it programmatically like:
var growingTextView: NextGrowingTextView!
growingTextView = NextGrowingTextView()
self.inputContainerView = growingTextView
self.view.addSubview(growingTextView)
And I got it working. But the problem is, it doesn’t change how it looks. cornerRadius and backgroundColor etc won’t work on it. Where am I gone wrong?
Any way I can use the Swift 2.2 version without cocoa pods? It won't work with carthige either
Hello Sir,
Thank you for making this nice control. But can you please tell me how can I get get delegates to be called inside my view control instead of View.swift?
Thanks
/Users/joelaws/Workspace/kratos/Pods/NextGrowingTextView/NextGrowingTextView/NextGrowingInternalTextView.swift:38:157: 'UITextViewTextDidChange' has been renamed to 'UITextView.textDidChangeNotification'
/Users/joelaws/Workspace/kratos/Pods/NextGrowingTextView/NextGrowingTextView/NextGrowingInternalTextView.swift:38:157: 'UITextViewTextDidChange' was obsoleted in Swift 4.2 (UIKit.NSNotification.Name)
How can I upgrade this to newer one?
let growingTextView: NextGrowingTextView
growingTextView.delegates.textViewDidChange = { (growingTextView: NextGrowingTextView) in
// Do something
}
Calling methods using delegate keeps the strong reference. Hence viewcontroller never deallocated.
is there TableView Sample ?
thanks muukii
keyboard not shown after tap inputview..
tap again, keyboard show
Please make this carthage compatible. It would be so much better that way. Thanks.
I'm very confused about this,usually I add a observer at viewControllers to listent the frame changes of the input view,I can't find any code about this feature,and in the example project, the input view always above the keyboard, even user change the type of keyboard the input view always follow the key board...please tell me why...thanks a lot
Hi, thanks for this great library.
I'm using this growing textview in chat app, but on landscape it is not showing the textview proper. And also when rotate from portrait to landscape it creates same problem.
Could I get this working on Swift 2.3? There’s no mention in the instructions.
Using v1.4.0 from cocoapods (latest as of the writing of this post).
In the file "NextGrowingInternalTextView.swift", the "addObserver" line from the code snippet below has an error with the name input parameter, saying "Type 'UITextView' has no member 'textDidChangeNotification'."
I have spent hours trying to determine why textDidChangeNotification is not being recognized. I have removed the dependency, added it back, cleaned, and rebuilt multiple times to no avail. Perhaps it is deprecated in Swift 4. Would appreciate some help on this. Thanks!
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
NotificationCenter.default.addObserver(self, selector: #selector(NextGrowingInternalTextView.textDidChangeNotification(_ :)), name: UITextView.textDidChangeNotification, object: self)
}
We now always have to access internal textView via wrapper.
This means the power of control was missing for non-supporting properties/methods.
We have an option that publishes internal textView to get the power back by just make public visibility of textView:
public let textView: NextGrowingInternalTextView
I think wrapper should not prevent accessing the content.
What do you think?
Please! Thanks!
Unable to call delegate methods. What is the delegates name ?
It would be great if you access the inner text view to set properties on it. I would like to be able to turn off the scroll indicator from showing on the inner text view.
// ViewController.swift
//
// Copyright (c) 2015 muukii
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import UIKit
import NextGrowingTextView
class ViewController: UIViewController {
@IBOutlet weak var inputContainerView: UIView!
@IBOutlet weak var inputViewBottom: NSLayoutConstraint!
@IBOutlet weak var growingTextView: NextGrowingTextView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
self.growingTextView.layer.cornerRadius = 4
self.growingTextView.backgroundColor = UIColor(white: 0.9, alpha: 1)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
self.view.endEditing(true)
}
@IBAction func handleSendButton(sender: AnyObject) {
self.growingTextView.text = ""
self.view.endEditing(true)
}
func keyboardWillHide(sender: NSNotification) {
if let userInfo = sender.userInfo {
if let _ = userInfo[UIKeyboardFrameEndUserInfoKey]?.CGRectValue.size.height {
//key point 0,
self.inputViewBottom.constant = 0
//textViewBottomConstraint.constant = keyboardHeight
UIView.animateWithDuration(0.25, animations: { () -> Void in self.view.layoutIfNeeded() })
}
}
}
func keyboardWillShow(sender: NSNotification) {
if let userInfo = sender.userInfo {
if let keyboardHeight = userInfo[UIKeyboardFrameEndUserInfoKey]?.CGRectValue.size.height {
self.inputViewBottom.constant = keyboardHeight
UIView.animateWithDuration(0.25, animations: { () -> Void in
self.view.layoutIfNeeded()
})
}
}
}
}
Try this code
Hi - any idea when full Swift 3 support will be ready? See some commits already, but having some issues even with latest release on master. Thanks!
What commit/tag/branch should I use for swift 2.3?
Tks
As the title suggests my placeholder doesn't seem to get set anymore?
Does it still support iOS 7?
There is an issue about height computation since version 1.0.0 (regression caused by commit 6f8dc60).
Step to reproduce :
In the example code, in viewDidLoad
function in ViewController.swift, set a big size font to the textView :
self.growingTextView.textView.font = UIFont.systemFont(ofSize: 40)
Result :
Waiting result :
I try to use this code and container go to its old frame
messageView is container
var frame = self.messageView.frame
frame.origin.y = self.view.frame.origin.y + messageView.frame.origin.y
UIView.animate(withDuration: 2, animations: {
self.messageView.frame = frame
})
how possible would it be to use this in an objective C project?
I tried to juggle with the tableview row height and autoConstaint yet with no luck.
I noticed that you have upgraded to Swift 3 now.
If I'm still using Swift 2, where can I get the latest codebase which is iOS 7 compatible? Is there a final commit id I can use?
i want to count the character into textview but text changing event is not called
Hi,
CocoaPods lists NextGrowingTextView
in the version 0.8.4, but that version can't be added to a Podfile. Actually, the page for the pod is broken: https://cocoapods.org/pods/NextGrowingTextView/
The version number in the podspec
for 0.8.4 is wrong, that might be the reason: https://github.com/muukii/NextGrowingTextView/blob/0.8.4/NextGrowingTextView.podspec
Thanks!
The code for drawing the placeholder does not take into account its actual size which depends on the font. Could be probably solved by computing the bounding size and offsetting the drawing rect.
I am using NextGrowingTextView adding all 3 files but always giving me issue No such module "NextGrowingTextView".
How to integrate NextGrowingTextView manually.
Placeholder color change option is not available.
textView edge inset not working.
Hi
I have a NextGrowingTextview with black background color and when I do begin editing I set the alpha of my black textview to 0.3f to get a transparent look.
The issue is when i type a character and then press the back button. the view resizes so the height becomes 1. Is this a known issue?
Hi, thanks for providing this lightweight controls.
I tried to enable the scrollview dismiss interactively but the view is not supported, then I try to mount it into accessoryView. It also didn't appear with stuck button at bottom right.
override func viewDidLoad() {
//...
self.growingTextView.removeFromSuperview()
}
override var inputAccessoryView:UIView{
get{
return self.growingTextView
}
}
I want to set enablesReturnKeyAutomatically, how to do it?
I don't think this is properly working on iOS 11. The text field stays at the bottom even when the keyboard comes up.
All use autolayout. If I set _textView.textContainerInset = UIEdgeInsets.init(top: 0, left: 10, bottom: 0, right: 10) and _textView.font = UIFont.systemFont(ofSize: 14), the NextGrowingInternalTextView.height is 17 and NextGrowingTextView.height is 35.3333. The _minHeight is computed to 35.333 and should it be 17?
public var returnKeyType: UIReturnKeyType {
get { return self.textView.returnKeyType }
set { self.textView.returnKeyType = newValue }
}
I set the property minNumberOfLines
to be 3, But his height is still the height of a line
I think the code for the bug is:
private func updateMinimumAndMaximumHeight() {
_minHeight = simulateHeight(1)
_maxHeight = simulateHeight(maxNumberOfLines)
fitToScrollView()
}
My test should be better like this:
private func updateMinimumAndMaximumHeight() {
_minHeight = simulateHeight(minNumberOfLines)
_maxHeight = simulateHeight(maxNumberOfLines)
fitToScrollView()
}
I hope to accept the comments, thank you very much.
There seems a bug when you rotate from landscape to portrait, the send button doesn't show, even added the necessary constraint
Hi @muukii ,
Currently, the view is not resizing properly with new line characters: \n if you try to calculate the systemLayoutSizeFiitingSize(UILayoutFittingCompressedSize) after receiving the didChangeHeight delegates event.
The reason is because it is being called before invalidating the intrinsic content size. In your code you have:
self.delegates.didChangeHeight(self.frame.height)
self.invalidateIntrinsicContentSize()
You should instead switch these two lines as follows and the problem is fixed:
self.invalidateIntrinsicContentSize()
self.delegates.didChangeHeight(self.frame.height)
Great component you have here. Keep up the good work 👍
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.