oseparovic / MessageComposerView

Custom UIView that sticks to the keyboard like in iMessage
MIT License
100 stars 27 forks source link

Problems compiling and running the MessageComposerView #10

Closed gosha999 closed 9 years ago

gosha999 commented 9 years ago

Hi, I am trying to integrate MessageComposerView in swift project using swift bridging header.

I had some compilation and some runtime issues.


Compilation: line 163: messageTextViewFrame.size.height = messageTextViewFrame.size.height - _composerBackgroundInsets.top; - _composerBackgroundInsets.bottom; Minus after semicolon makes compiler warning - not sure if semicolon should be removed or the rest of the line should be commented

[NSString isEmpty:textView.text] in couple of places in code generates error: isEmpty is an unknown method. I replaced it meanwhile with [textView.text length] == 0


Runtime: When I get to the ViewController integrated with MessageComposerView I just don't see anything. This is the code in ViewController

class Reply2ViewController: UIViewController, MessageComposerViewDelegate {

var composer: MessageComposerView!;

override func viewDidLoad() {
    super.viewDidLoad()

    //composer = MessageComposerView(keyboardOffset: 0, andMaxHeight: 200.0);
    composer = MessageComposerView();
    composer.delegate = self;

    self.view.addSubview(composer);
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func messageComposerSendMessageClickedWithMessage(message: String!) {
}

}

I instantiate it with the following code:

contentViewControllers[TiktekStateType.REPLY] = Reply2ViewController(nibName: "Reply2ViewController", bundle: nil);

The xib file contains nothing on this stage.

The view controller is displayed in a situation when user wants to reply to a message.

I would be very grateful for any tip on what I possibly did wrong.

Thank you,

Igor Goldberg

oseparovic commented 9 years ago

Hi Igor,

First of all thanks for pointing out the compilation errors. XCode ignored that semi-colon, and I let my integration perhaps get a little too close to my test project. Those should be fixed now.

As for why the composer isn't appearing, have you tried adding the following self.edgesForExtendedLayout = UIRectEdgeNone; to your viewDidLoad implementation? It would also be helpful to know which device + OS version you're testing this against and whether or not your navigation bar is translucent.

Thanks!

oseparovic commented 9 years ago

It also might be helpful to try using the "Debug View Hierarchy" option if you're using XCode. It might show where the MessageComposerView has gone if it has been moved offscreen.

gosha999 commented 9 years ago

Thank you for your prompt response.

I am running in iPhone6 emulator with iOS 8.2. self.edgesForExtendedLayout = UIRectEdgeNone; did not have effect.

I did not use standard navigation bar and toolbar, instead there are some custom controls performing these functions (thats because I am porting an android application to iOS and trying to keep Java and Swift application organised in similar way, including navigation mechanism that manually loads and switches ViewControllers).

Also thank you the "Debug View Hierarchy" tip - I was not aware that it exists, and found it very helpful. It turned out that MessageComposer is located under the bottom of the screen. I attach the screenshot of view hierarchy.

Can I modify my code to set the offset of MessageComposer from screen bottom manually?

screen shot 2015-04-06 at 10 11 30 pm

oseparovic commented 9 years ago

self.edgesForExtendedLayout = UIRectEdgeNone; did nothing likely because of the custom porting you're doing. MessageComposerView depends on standard iOS navigation bar and view layout.

If you're interested in making it work for your custom implementation you'll have to tweak the currentScreenSizeInInterfaceOrientation: method within the MessageComposerView lib. This function is used to determine the Y position (based on screen height) and width (based on screen width).

Let me know if that helps!

P.S. if it's not too late I would highly advise against this path you're heading down. You'll likely spend more time wrangling with infuriating compatibility issues than you would if you were just to build the application using standard iOS libs instead.

gosha999 commented 9 years ago

Thank you very much for this explanation. I see that I have some homework to do with the application design in general. I will also try to play with currentScreenSizeInInterfaceOrientation implementation.