Coder Social home page Coder Social logo

fluidgroup / nextgrowingtextview Goto Github PK

View Code? Open in Web Editor NEW
1.8K 31.0 147.0 7.81 MB

📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.

License: MIT License

Swift 97.57% Ruby 2.43%
ios carthage xcode textview cocoapods hacktoberfest

nextgrowingtextview's People

Contributors

akhrameev avatar blackjacx avatar econa77 avatar fossabot avatar gokhanakkurt avatar haowenwu avatar helptan avatar hiromi2424 avatar igorkulman avatar menayousif avatar mlight3 avatar muukii avatar ntnmrndn avatar philippeauriach avatar pinda avatar shima11 avatar simonbs avatar takumatt avatar tlc-10 avatar uplikevincent avatar ximximik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nextgrowingtextview's Issues

Swift 2.3 version?

Could I get this working on Swift 2.3? There’s no mention in the instructions.

Cannot hide container

   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
})

Not working on orientation change.

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.

Set _textView.textContainerInset makes wrong size

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?

Swift 3 support

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!

Unexpectedly found nil

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?

Use without cocoapods

Any way I can use the Swift 2.2 version without cocoa pods? It won't work with carthige either

Carthage Compatible!

Please make this carthage compatible. It would be so much better that way. Thanks.

swift 2.3

What commit/tag/branch should I use for swift 2.3?
Tks

Enhancement request

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 👍

MinHeight is 1 when no there is no text in the view.

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?

Swift Compiler Error: Type 'UITextView' has no member 'textDidChangeNotification'

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)
  }

keyboard not show

keyboard not shown after tap inputview..
tap again, keyboard show

Is this still iOS 7 compatible?

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?

Access internal textView dynamically

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?

Help

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

Placeholder not vertically centered

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.

Dismiss interactively

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
        }
    }

minHeight

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.

XCode 10 GM and Swift 4.2 fail to build

/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)

There is wrong with your viewController

// 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

Access To Inner Text View

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.

About the Example,why the inputAccessoryView always above the keyboard?

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

Swift 2.2/2.3?

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.

Not working on iOS 11?

I don't think this is properly working on iOS 11. The text field stays at the bottom even when the keyboard comes up.

Height issue with placeholder

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 :

Result

Waiting result :

Waiting result

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.