Giter Site home page Giter Site logo

phfcomposebarview's Introduction

PHFComposeBarView

demo

More screenshots: without text and with text.


This is a precise reconstruction of the compose bar from the iOS Messages.app, mimicking the behaviors and graphics while also allowing you to customize many aspects of it.

It basically consists of a text view, a placeholder label, a utility button located to the left of the text view, and a main button located to the right of the text view.

If you're looking for something that works with iOS 5 and 6 featuring the old look and feel, have a look at version 1.1.1.

Features

  • title of main button (the one on the right) can be changed
  • tint color of main button can be changed
  • title of the placeholder can be changed
  • placeholder is exposed as a property for further customization
  • text view is exposed as a property for further customization
  • utility button (the one on the left) can be shown by setting the utility button image (best results for gray images (~56% white) on transparent background with up to 50pt side length)
  • optional character counter when specifying a max character count (similar to typing an SMS in Messages.app; the max char count limit is not imposed)
  • uses delegation to notify of button presses
  • forwards delegation methods from the text view
  • automatically grows when text wraps
  • posts notifications and sends delegate messages about frame changes before and after the change so you can adjust your view setup
  • by default grows upwards, alternatively downwards
  • max height for growth can be specified in terms of points or line numbers
  • has a translucent blurred background

Installation

The prefered way is to use CococaPods.

pod 'PHFComposeBarView', '~> 2.0.1'

If you can't use CocoaPods for some reason (you really should though, it's the cool kid on the block), then grab the files in Classes/ and put it in your project. The code uses ARC, so make sure to turn that on for the files if you're not already using ARC. There's a dependency on PHFDelegateChain, so make sure to add that to your project, too.

Usage

The compose bar visible in the demo above was created as follows:

CGRect viewBounds = [[self view] bounds];
CGRect frame = CGRectMake(0.0f,
                          viewBounds.size.height - PHFComposeBarViewInitialHeight,
                          viewBounds.size.width,
                          PHFComposeBarViewInitialHeight);
PHFComposeBarView *composeBarView = [[PHFComposeBarView alloc] initWithFrame:frame];
[composeBarView setMaxCharCount:160];
[composeBarView setMaxLinesCount:5];
[composeBarView setPlaceholder:@"Type something..."];
[composeBarView setUtilityButtonImage:[UIImage imageNamed:@"Camera"]];
[composeBarView setDelegate:self];

To get notified of button presses, implement the optional methods from the PHFComposeBarViewDelegate protocol:

- (void)composeBarViewDidPressButton:(PHFComposeBarView *)composeBarView;
- (void)composeBarViewDidPressUtilityButton:(PHFComposeBarView *)composeBarView;

To get notified of frame changes, either listen to the notifications (PHFComposeBarViewDidChangeFrameNotification and PHFComposeBarViewWillChangeFrameNotification) or implement the optional delegate methods:

- (void)composeBarView:(PHFComposeBarView *)composeBarView
   willChangeFromFrame:(CGRect)startFrame
               toFrame:(CGRect)endFrame
              duration:(NSTimeInterval)duration
        animationCurve:(UIViewAnimationCurve)animationCurve;
- (void)composeBarView:(PHFComposeBarView *)composeBarView
    didChangeFromFrame:(CGRect)startFrame
               toFrame:(CGRect)endFrame;

Note that all methods from the UITextViewDelegate protocol are forwarded, so you can add your own behavior to the text view such as limiting the text length etc.

Refer to PHFComposeBarView.h for the available properties and their descriptions.

Small Print

License

PHFComposeBarView is released under the MIT license.

Dependencies

Author

Philipe Fatio (@fphilipe)

Sponsors

These people and companies have sponsored the development so far:

phfcomposebarview's People

Contributors

bitdeli-chef avatar fphilipe avatar jamesbebbington avatar slycrel 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phfcomposebarview's Issues

UIBarStyleBlackTranslucent?

Is it possible you implemented a dark version of this? Because It would help a lot as you can see in my screenshot.
img_7215

Only show compose bar on keyboard

Is there a way to disable displaying the compose bar at the bottom, and only show it on the keyboard? I'd like a button to trigger the keyboard instead of having the bar there permanently. Thanks!

UIToolbar example

I've been testing PHFComposeBarView inside of a UIToolbar, but it doesn't seem to work on iOS7. Has anybody managed to resize the height of the UIToolBar when embedded inside of a UINavigationController?

Resign First Responder not working with Swift

Hey

For some reason I can never get the view/keyboard to disappear with resignFirstResponder or endEditing. I manage to make it go when the view closes but only by doing UIApplication.sharedApplication().sendAction(Selector("resignFirstResponder"), to: nil, from: nil, forEvent: nil) which is pretty aggressive.

Any thoughts on what my be causing it to stick? I am using Swift 2.1.1 and iOS 9.2

Globally selected text & Image paste

Hello,

I working PHFComposeBarView for chat application. I want to use paste option in text view if i already selected image or text from application or out of application.

In iOS 7+, caret is not tracked correctly when return is pressed

Caret tracking works fine if the text is allowed to overflow naturally, but if the user creates new lines with the return key, the caret goes offscreen once the max number of lines is reached. The user can scroll down manually, but as soon as they type, the text view scrolls back to where it was.

We tracked the problem down to the textHeight function. Unfortunately, iOS 7+ introduces side effects to the sizeThatFits: method, so a call to textHeight was interfering with the caret tracking code.

One workaround is to create a copy of the text field and call sizeThatFits: on the copy instead of the real text field.

Textview not accessible to UI tests

Hey @fphilipe, we have an app that makes much use of PHFComposeBarView and as we're aiming to translate it into a couple of dozen languages, we're very keen to make use of UI Tests to automate UI testing, screenshots and video walkthroughs for our translators. Unfortunately we're having problems entering text into the ComposeBar programatically.

It looks like the core of the issue is that the text view is not visible to the underlying accessibility framework that UI Tests depend on.

I've created a minimal test case using your Example app that exhibits the issue. While it's possible to tap the ComposeBar and give the textview focus, the test framework then can't find any textview to type text into.

screen shot 2017-01-18 at 15 36 32

I've added some acessibilityIdentifiers to help make addressing specific elements easier, but if you look at the application's element subtree that's dumped to the test log, you should be able to see that there's no sign of any textview:

2017-01-18 14:41:55.352 XCTRunner[26241:2566947] Running tests...
2017-01-18 14:41:56.955 XCTRunner[26241:2566947] Continuing to run tests in the background with task ID 1
Test Suite 'Selected tests' started at 2017-01-18 14:41:57.493
Test Suite 'PHFComposeBarViewExampleUITests.xctest' started at 2017-01-18 14:41:57.494
Test Suite 'PHFComposeBarViewExampleUITests' started at 2017-01-18 14:41:57.494
Test Case '-[PHFComposeBarViewExampleUITests.PHFComposeBarViewExampleUITests testComposeBar]' started.
    t =     0.00s     Start Test at 2017-01-18 14:41:57.495
    t =     0.00s     Set Up
    t =     0.01s     Launch com.philipefatio.PHFComposeBarViewExample
    t =     5.06s         Waiting for accessibility to load
    t =     6.75s         Wait for app to idle
    t =     8.19s     Tap Button
    t =     8.19s         Wait for app to idle
    t =     8.22s         Find the Button
    t =     8.22s             Snapshot accessibility hierarchy for com.philipefatio.PHFComposeBarViewExample
    t =     8.51s             Find: Descendants matching type Other
    t =     8.52s             Find: Elements matching predicate '"PHFComposeBar" IN identifiers'
    t =     8.52s             Find: Descendants matching type Button
    t =     8.52s             Find: Element at index 1
    t =     8.53s             Wait for app to idle
    t =     8.56s         Synthesize event
    t =     8.81s         Wait for app to idle
    t =     9.80s     Type 'Here is some sampl...' into Target Application 0x6080000b2780
    t =     9.80s         Wait for app to idle
    t =     9.86s         Find the Target Application 0x6080000b2780
    t =     9.86s             Snapshot accessibility hierarchy for com.philipefatio.PHFComposeBarViewExample
    t =    10.94s             Wait for app to idle
    t =    11.33s         Synthesize event
    t =    11.39s             Assertion Failure: PHFComposeBarViewExampleUITests.swift:24: UI Testing Failure - Neither element nor any descendant has keyboard focus. Element:
Attributes: Application 0x608000165a00: {{0.0, 0.0}, {320.0, 568.0}}, label: 'PHFComposeBarViewExample'
Element subtree:
 →Application 0x608000165a00: {{0.0, 0.0}, {320.0, 568.0}}, label: 'PHFComposeBarViewExample'
    Window 0x6080001651c0: Main Window, {{0.0, 0.0}, {320.0, 568.0}}
      Other 0x608000166c00: traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}
        Other 0x608000164500: traits: 8589934592, {{0.0, 0.0}, {320.0, 315.0}}
          TextView 0x608000165c40: traits: 140746078289984, {{0.0, 20.0}, {320.0, 295.0}}, value: Welcome to the Dem...
          Other 0x608000166540: traits: 8589934592, {{0.0, 271.0}, {320.0, 44.0}}, identifier: 'PHFComposeBar'
            Other 0x6080001669c0: traits: 8589934592, {{0.0, 271.0}, {320.0, 0.5}}
            Toolbar 0x608000166840: traits: 35192962023424, {{0.0, 271.5}, {320.0, 44.0}}
            Button 0x6080001660c0: traits: 8589934593, {{8.0, 281.0}, {25.0, 25.0}}, identifier: 'PHFComposeBarUtilityButton', label: 'Camera'
            Button 0x608000166fc0: traits: 8589934593, {{41.0, 279.0}, {224.0, 28.0}}
            Button 0x608000165580: traits: 8589934849, {{267.0, 281.0}, {53.0, 26.0}}, identifier: 'PHFComposeBarButton', label: 'Send'
    Window 0x608000166e40: {{0.0, 0.0}, {320.0, 568.0}}
      Other 0x608000167080: traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}
        Other 0x608000167200: traits: 8589934592, {{0.0, 315.0}, {320.0, 253.0}}
          Other 0x6080001675c0: traits: 8589934592, {{0.0, 315.0}, {320.0, 253.0}}
    Window 0x608000167440: {{0.0, 0.0}, {320.0, 568.0}}
      StatusBar 0x6080001678c0: {{0.0, 0.0}, {320.0, 20.0}}
        Other 0x608000167800: {{0.0, 0.0}, {320.0, 20.0}}
        Other 0x608000167980: {{0.0, 0.0}, {320.0, 20.0}}
          Other 0x608000167b00: traits: 8388608, {{6.0, 0.0}, {39.0, 20.0}}
          Other 0x608000167bc0: traits: 8388608, {{50.0, 0.0}, {13.0, 20.0}}, label: '3 of 3 Wi-Fi bars', value: SSID
          Other 0x608000167d40: traits: 8389120, {{137.0, 0.0}, {50.0, 20.0}}, label: '2:42 PM'
          Other 0x608000167c80: traits: 8388608, {{282.0, 0.0}, {33.0, 20.0}}, label: '-100% battery power'
    Window 0x608000167e00: {{-0.0, -0.0}, {320.0, 568.0}}
      Other 0x608000167ec0: traits: 8589934592, {{-0.0, -0.0}, {320.0, 568.0}}
        Other 0x608000167f80: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
          Other 0x608000168040: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
            Other 0x608000168100: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x6080001681c0: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x608000168280: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x608000168340: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x608000168580: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x608000168700: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
          Other 0x608000168a00: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
            Keyboard 0x608000168b80: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
              Other 0x608000168c40: traits: 8589934592, {{-0.0, 315.0}, {320.0, 253.0}}
                Other 0x608000168d00: traits: 8589934592, {{-0.0, 315.0}, {320.0, 38.0}}, label: 'Typing Predictions'
                  Other 0x608000168dc0: traits: 8589934592, {{-0.0, 315.0}, {320.0, 38.0}}
                    Image 0x608000169000: traits: 8589934596, {{-0.0, 315.0}, {320.0, 38.0}}
                  Other 0x608000168f40: traits: 9126805504, {{-0.0, 315.0}, {106.0, 38.0}}, label: 'I'
                  Other 0x6080001690c0: traits: 9126805504, {{107.0, 315.0}, {106.0, 38.0}}, label: 'The'
                  Other 0x608000169480: traits: 9126805504, {{214.0, 315.0}, {106.0, 38.0}}, label: 'I'm'
                Other 0x608000169540: traits: 35192962023424, {{-0.0, 352.0}, {320.0, 216.0}}
                  Key 0x608000169600: traits: 8589934640, {{-0.0, 363.0}, {32.0, 42.0}}, label: 'Q'
                  Key 0x6080001696c0: traits: 8589934640, {{32.0, 363.0}, {32.0, 42.0}}, label: 'W'
                  Key 0x608000169840: traits: 8589934640, {{64.0, 363.0}, {32.0, 42.0}}, label: 'E'
                  Key 0x608000169900: traits: 8589934640, {{96.0, 363.0}, {32.0, 42.0}}, label: 'R'
                  Key 0x6080001699c0: traits: 8589934640, {{128.0, 363.0}, {32.0, 42.0}}, label: 'T'
                  Key 0x608000169a80: traits: 8589934640, {{160.0, 363.0}, {32.0, 42.0}}, label: 'Y'
                  Key 0x608000169b40: traits: 8589934640, {{192.0, 363.0}, {32.0, 42.0}}, label: 'U'
                  Key 0x608000169c00: traits: 8589934640, {{224.0, 363.0}, {32.0, 42.0}}, label: 'I'
                  Key 0x608000169cc0: traits: 8589934640, {{256.0, 363.0}, {32.0, 42.0}}, label: 'O'
                  Key 0x608000169d80: traits: 8589934640, {{288.0, 363.0}, {32.0, 42.0}}, label: 'P'
                  Key 0x608000169e40: traits: 8589934640, {{16.0, 417.0}, {32.0, 42.0}}, label: 'A'
                  Key 0x608000169f00: traits: 8589934640, {{48.0, 417.0}, {32.0, 42.0}}, label: 'S'
                  Key 0x608000169fc0: traits: 8589934640, {{80.0, 417.0}, {32.0, 42.0}}, label: 'D'
                  Key 0x60800016a080: traits: 8589934640, {{112.0, 417.0}, {32.0, 42.0}}, label: 'F'
                  Key 0x60800016a140: traits: 8589934640, {{144.0, 417.0}, {32.0, 42.0}}, label: 'G'
                  Key 0x60800016a200: traits: 8589934640, {{176.0, 417.0}, {32.0, 42.0}}, label: 'H'
                  Key 0x60800016a2c0: traits: 8589934640, {{208.0, 417.0}, {32.0, 42.0}}, label: 'J'
                  Key 0x60800016a380: traits: 8589934640, {{240.0, 417.0}, {32.0, 42.0}}, label: 'K'
                  Key 0x60800016a440: traits: 8589934640, {{272.0, 417.0}, {32.0, 42.0}}, label: 'L'
                  Button 0x60800016a500: traits: 8589934649, {{-0.0, 471.0}, {42.0, 42.0}}, identifier: 'shift', label: 'shift'
                  Key 0x60800016a5c0: traits: 8589934640, {{48.0, 471.0}, {32.0, 42.0}}, label: 'Z'
                  Key 0x60800016a680: traits: 8589934640, {{80.0, 471.0}, {32.0, 42.0}}, label: 'X'
                  Key 0x60800016a740: traits: 8589934640, {{112.0, 471.0}, {32.0, 42.0}}, label: 'C'
                  Key 0x60800016a800: traits: 8589934640, {{144.0, 471.0}, {32.0, 42.0}}, label: 'V'
                  Key 0x60800016a8c0: traits: 8589934640, {{176.0, 471.0}, {32.0, 42.0}}, label: 'B'
                  Key 0x60800016a980: traits: 8589934640, {{208.0, 471.0}, {32.0, 42.0}}, label: 'N'
                  Key 0x60800016aa40: traits: 8589934640, {{240.0, 471.0}, {32.0, 42.0}}, label: 'M'
                  Key 0x60800016ab00: traits: 9663676464, {{278.0, 471.0}, {42.0, 42.0}}, identifier: 'delete', label: 'delete'
                  Key 0x60800016abc0: traits: 8589934640, {{-0.0, 525.0}, {40.0, 42.0}}, identifier: 'more', label: 'more, numbers'
                  Button 0x60800016ac80: traits: 8589934641, {{40.0, 525.0}, {40.0, 42.0}}, label: 'Next keyboard', value: Emoji
                  Button 0x60800016ad40: traits: 8589936689, {{80.0, 525.0}, {32.0, 42.0}}, identifier: 'dictation', label: 'Dictate'
                  Key 0x60800016ae00: traits: 8589934640, {{112.0, 525.0}, {128.0, 42.0}}, label: 'space'
                  Button 0x60800016aec0: traits: 8589934641, {{240.0, 525.0}, {80.0, 42.0}}, identifier: 'Return', label: 'return'
Path to element:
 →Application 0x608000165a00: {{0.0, 0.0}, {320.0, 568.0}}, label: 'PHFComposeBarViewExample'
Query chain:
 →Find: Target Application 0x6080000b2780
  Output: {
    Application 0x608000165a00: {{0.0, 0.0}, {320.0, 568.0}}, label: 'PHFComposeBarViewExample'
  }

    t =    11.42s     Tear Down
Test Case '-[PHFComposeBarViewExampleUITests.PHFComposeBarViewExampleUITests testComposeBar]' failed (11.761 seconds).
Test Suite 'PHFComposeBarViewExampleUITests' failed at 2017-01-18 14:42:09.257.
	 Executed 1 test, with 1 failure (0 unexpected) in 11.761 (11.763) seconds
Test Suite 'PHFComposeBarViewExampleUITests.xctest' failed at 2017-01-18 14:42:09.258.
	 Executed 1 test, with 1 failure (0 unexpected) in 11.761 (11.764) seconds
Test Suite 'Selected tests' failed at 2017-01-18 14:42:09.258.
	 Executed 1 test, with 1 failure (0 unexpected) in 11.761 (11.766) seconds


Test session log:
	/Users/james/Library/Developer/Xcode/DerivedData/PHFComposeBarViewExample-foxaqozujhvretgsawvddytmcqux/Logs/Test/6895D49B-2F01-4FC1-89F1-2D93011CBAB9/Session-PHFComposeBarViewExampleUITests-2017-01-18_144146-qXDaXR.log

I suspect that this may be related to the fact that the textView is a child of a button, as brought up in #36. I'm sure you had good reason to nest the textview in the button, I'd much appreciate it if you could give us some background so that we can fix or workaround this issue.

Many thanks.

Insert images

Is it possible to inline images in text field?
Maybe you have an idea to do so?
I am ready to contribute...

crash on iOS7 when pressing return on an empty line.

How to reproduce:

Focus the textfield, press return, it crashes.

The cause

[[self textView] caretRectForPosition:position].origin.y returns inf instead of a regular float.

Hack to prevent from crashing

Ask the method to do nothing if the value is inf

        // Caret is above visible part of text view:
        if (relativeCaretY < 0.0f) {
            offsetYDelta = relativeCaretY;
        }
        // Caret is in or below visible part of text view:
        else if (relativeCaretY > 0.0f) {
            CGFloat maxY = [self bounds].size.height - PHFComposeBarViewInitialHeight;
            // Caret is below visible part of text view:
            if (relativeCaretY > maxY)
                offsetYDelta = relativeCaretY - maxY;
        }

to:

        // Caret is above visible part of text view:
        if (relativeCaretY < 0.0f && relativeCaretY < DBL_MAX) {
            offsetYDelta = relativeCaretY;
        }
        // Caret is in or below visible part of text view:
        else if (relativeCaretY > 0.0f && relativeCaretY < DBL_MAX) {
            CGFloat maxY = [self bounds].size.height - PHFComposeBarViewInitialHeight;
            // Caret is below visible part of text view:
            if (relativeCaretY > maxY)
                offsetYDelta = relativeCaretY - maxY;
        }

It's a hack so I cannot make a pull request. If anybody has a nicer solution...
Thank you!

Regarding Default size increase when load composebar

Hello,

I am using compose bar for my chat application. Application is responsive from as per default font style from setting(Font Zoom Increase Decrease) style. So If font size is larger 53 then change compose bar view in height as default UI for single line text message.

Thanks,

keyboard hide textfield

hi! thanks for this awesome work!

i was wandering about if you can help me with my issue, the textfield doesnt move above the keyboard when you tap on it. thankss

Issue on iOS8 with predictive bar

Awesome component!!! But there is an issue on iOS8 with the predictive bar above the keyboard. The component is below it ;)
Thanks.

Crash while setting the delegate: Acessibility?

Hi,

I've just gone live with an app using the excellent PHFComposeBarView. I've seen a few crashes over the last couple of days when setting the delegate. I'm suspecting something to do with Accessibility (due both to the word appearing in the crash report, and the fact that it seems to be consistently affecting 2 users, but no-one else). It's iOS8 only, and affecting both iPhone 5S and 6+.

The crash report is here: http://crashes.to/s/0321516c355 but I've screens hotted the salient piece here:
2014-10-06_1109

I'm not expecting you to fix my bugs :-) But I just wondered if anyone else had seen it and/or figured it out.

Thanks again for a really useful component.

Alan

Unable to scroll to caret after inserting NSTextAttachment in textView

I am adding images to compose bar’s textview using NSTextAttachment. But when I add more than 2-3 images, textview is not exactly scrolling to caret. Also when I have a combination of text and images (image at last) and when I tap on last line of compose bar, it does not scroll to last line, it scrolls on first or second line or image. Please check my code :

let attachment = ChatTextAttachment()
attachment.image = thumbImage

// Add NSTextAttachment into attributedString
let attributedString = NSMutableAttributedString(string: "", attributes: [NSFontAttributeName:UIFont.systemFontOfSize(14)])
let attrStringWithImage = NSAttributedString(attachment: attachment)
attributedString.appendAttributedString(attrStringWithImage)
attributedString.appendAttributedString(NSAttributedString(string: "\n", attributes: [NSFontAttributeName:UIFont.systemFontOfSize(14)]))

// Add this attributed string to the current position.
self.composeBar.textView.textStorage.insertAttributedString(attributedString, atIndex: self.composeBar.textView.selectedRange.location)
self.composeBar.textView.select(self)
self.composeBar.textView.selectedRange = NSMakeRange(self.composeBar.textView.attributedText.length, 0 );

self.textViewDidChange(self.composeBar.textView)
self.composeBar.textView.layoutIfNeeded()

ChatTextAttachment is a subclass of NSTextAttachment
Let me know if you need any more details.

Subview layout incorrect if not allocated using initWithFrame:

Creating a PHFComposeBarView in the following form will result in incorrect sizes for subviews:

PHFComposeBarView *view = [PHFComposeBarView new];
view.frame = CGRectMake(...);

However, this form does work as expected:

PHFComposeBarView *view = [[PHFComposeBarView alloc] initWithFrame:CGRectMake(...)];

Rotation messes up text

When entering text with newlines interspersed, rotating will cause text to disappear from the view, until the delete key is pressed, upon which it returns visible.

To re-create: Enter text, return twice, enter text, immediately rotate.

Why is the textView inside a button?

Hi, I was trying to customize the textView's border to be square and clear, but then I discovered that the border was generated by the button that encloses the textView.

I see that the only function of the button is to becomeFirstResponder. Why is this necessary? Isn't tapping on the textView enough to cause it to take first responder?

Having the button that encloses the textview causes some problems with Accessibility, since I cannot really set the label on the button in a non-hacky way.

Keyboard covers text field

When I add the PHFComposeBarView to my UIVIew, and tap the textfield, the keyboard covers the textfield. How can make the textfield move up with the keyboard.

Thanks.

Attachment cancel button on image of NSTextAttachment

I want to show cross button on top right image for cancel attachment in NSTextAttachment and remove image from text view using particular cross button of that object without use keyboard cursor. Please let me know a way so i can achieve customizations on NSTextAttachment.

--Thanks In Advance

Not scrolling when hitting return

It scrolls perfectly when a new line is created by typing off the end of a line, but if I hit return to add new lines, it doesn't scroll for me — the caret y position just increases off into the unseen ether.

Does anyone else see this behavior? Or did I set something up incorrectly?

Thanks,

Russell.

Demo and this control does not work iOS7

Do you have a workable demo for iOS7? I tried it on an app using the Pod installer and textfield did not expand vertically when more text was added. Also composeBarViewWillChangeFrame does not fire even after adding notifications for it in my app

Is the purpose to mimic the iMessage app 100%?

I have altered the library code in my app a bit to function more as one would expect.

Namely, I altered button enabling:

- (void)updateButtonEnabled {
    BOOL enabled = [self isEnabled] && [[[[self textView] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0;

    if (_maxCharCount > 0) {
        enabled = [[[[self textView] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] <= _maxCharCount;
    }

    [[self button] setEnabled:enabled];
}

I think this functions a lot more as someone would expect. You do nearly all your checks on the trimmed string, so one would expect the button enabling to be the same. In the above, the button is enabled only when the length of the trimmed textView text is greater than 0 and when it is less than the maxCharCount if the maxCharCount was set.

If the purpose is to 100% mimic the iMessage app, then I won't submit a pull-request, just figure this is more intuitive with how one would expect.

Compose bar doesn't respond to paste board

I am using "VGPlayer" a third party liberary in my chat app, but after integrating this in my app. my compose bar doesn't responding paste options. Only compose bar didn't works fine but in other screens in textview or textfield paste board working.
Please suggest me how would I fix this.

iOS 6 deprecations

There are some items deprecated in iOS 6 - with iOS 7 coming out it makes sense to make code that supports 6 and 7 so it would be nice if the following could be cleaned up (to avoid deprecation warnings in Xcode and move on to using Apple's latest):

setMinimumFontSize: is deprecated. Should use minimumScaleFactor instead.
UITextAlignmentCenter is deprecated. Should use NSTextAlignmentCenter instead.

Happy to submit a pull request if you'll take it.

iOS 7 theme

Adjust appearance to match the iOS 7 style.

Supporting iOS 6 and iOS 7 themes through conditional compilation would be even better.

The frame change notifications should be a delegate callback, not a notification

It's a bit inconvenient (and unnecessarily unsafe, I might add) to use notifications for the compose bar frame change stuff. It would be much nicer if it were a delegate method.

The only reason I can think of for using notifications here is to mirror the UIKeyboard API; but I suggest that the UIKeyboard API is done in the way it is because there's not any particular UIKeyboard object that the consumer can get his/her hands onto and guarantee an exclusive delegate-relation. But that's not the case here: there's a clear owner to the compose bar, and the delegate relation is the most convenient one, I think.

Thanks for the very nice component, by the way!

Swift/AutoLayout : Bar stays under keyboard when keyboard is presented

Hi there =)

Though I already user PHFComposeBarView successfully in the past, I needed to use it in a swift project, but the ComposeBarView stays under the keyboard all the time.

I didn't have the time to figure out if this was an auto layout issue, or a swift issue (though my first guess would be AutoLayout). Did anyone had the same issue?

Thanks.

Text in composeBar is hidden.

When I write two lines, I press return and I write only letter the text inside in composeBar is hidden.

How to reproduce:

1. Write two lines 2. Press return and write only 1 letter

schermata 19 set 2013 18 28 08 simulatore ios

Attachment cancel button on image of NSTextAttachment

I want to show cross button on top right image for cancel attachment in NSTextAttachment and remove image from text view using particular cross button of that object without use keyboard cursor. Please let me know a way so i can achieve customizations on NSTextAttachment.

--Thanks In Advance

ComposeBar frame update issue using Autolayout update ?

Hi, I am working for chat application and using PHFComposeBar for message input. I implemented compose bar through autolayout. But compose bar not updating automatically and not updating table bottom when text editing and open editing mode, which is above compose bar.

I have to implement bottom display message position same in every case for updating text or open compose bar.

Please help me...

Mutliline text is cut

I have an issue when I use the composeBar to enter more than a line , the first one is displayed correctly the lines after are being cut and not visible.
Check attached photo
issue

PHFComposeBar via storyboards

Hi there. I really like PHFComposeBar, it's working great for me!

I was able to get this to work with storyboards with one small tweak. Adding an awakeFromNib method like this:

- (void)awakeFromNib
{
  [super awakeFromNib];

  [self calculateRuntimeConstants];
  [self setup];
}

This is essentially mirroring the init call. This helped greatly with not having to mix in-code autoLayout constraints with IB constraints. Thanks for the great drop-in class!

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.