UIViewController is already set up but I want to use SlackTextViewController - ios

How can I still maintain my storyboard view controller and add SlackTextViewController for my keyboard and input purposes?

No need for crazy hacks. Simply subclass SLKTextViewController instead of UIViewController and it will just work. Have a look at the sample projects too, they are very useful!

Present the slack view controller modally and set the background clear if you want so you can see your presenting view controller underneath. When you enter the text and the user presses send, send the text back to your other view controller with a notification and do whatever you want with it there.

Related

UIAlertController as Child View Controller

In order to allow for better customization in my app, I want to put UIAlertController within a UIViewController subclass. The alert should be a child of the UIViewController to allow for more flexibility.
What is the best way to achieve this?
I have tried so far to add the alert as a child view controller. When I want the alert to show up, I present the container view controller modally.
I have also tried to call presentViewController on the view controller (with the alert as a parameter). However, I'm not sure what the correct approach is to achieve what I am looking for.
Edit: Neither of these solutions were working as I had hoped, but I don't know if that is because I did something wrong or because the approach is wrong.
Edit 2: The added functionality is providing UIKeyCommands to make selection of the alert options easier. I am not subclassing UIAlertController for two reasons: (1) the documentation states that it should not be subclassed, and (2) adding key commands UIAlertController doesn't work.
Could you please explain what sort of flexibility such an approach provides? I'm not doubting that it does, as I'm relatively new to iOS development, but I can't quite figure out what you're trying to achieve using a child view controller.
If you simply want to present a UIAlertController from your view controller, just create the alert controller, configure it, and use presentViewController to display it.
As a general approach, however, I follow the advice found in the top answer in this thread. It suggests using either a UIAlertController subclass or category with a custom show method that provides the alert controller with its own window so that alerts can be presented 'globally' so to speak.
I don't think your question is absolutely clear, but maybe you want a custom pop-up view controller, not alert? Then you probably need something like STPopupController - it's customisable and easy to use.

My view automatically goes up when keyboard come in ios

In my storyboard I have two navigation controllers, say A and B. I bring NavB as a modal controller when a button is clicked on NavA. I have a textfield in my NavB. I have connected this textfield to the controller from storyboard and also have set the textfield delegate. When I click on this textfield, my view automatically animates up. I did some research and found that this happens when I set the delegate for textfield. This dont happen when I push my controller.
I have no clue how to fix it.
Please help!
I believe your viewController is UITableViewContoller, no?
The autoscroll-behavior is located in the UITableViewController functionality. To disable the automatic scrolling there are two ways:
use instead of the UITableViewController simply a UIViewController - set the datasource and delegate on your own.
Override the viewWillAppear-Routine - and DONĀ“T call [super viewWillAppear: animated].
Hope this fixes your issue, cheers :)
I would like to just make sure that your view is not a class of TPKeyboardAvoiding. Since its description says that:
A drop-in universal solution for moving text fields out of the way
of the keyboard in iOS
I have used in the login/sign controllers and observed that when a UITextField goes in edit mode, the TextField goes out of the way and view scrolls accordingly.
I fixed the issue. I had unticked 'Under top bars' in the storyboard and thats why i was getting this behaviour.

How to find the name of the view controller beneath a popover ios7

This is probably a very simple question but I can't find the answer to it.
I am working on a new project that uses Storyboards for the first time.
I have a number of view controllers that connect the way I want them to.
Each view controller has an info button.
I have one view controller (AboutViewController) that I want to use to display the info for all the view controllers. I am currently calling this via a popover segue from each screen. So I have one destination view controller (AVC) that I am calling from a number of VCs- VC1toAVC, VC2toAVC, VC3toAVC etc. I want two textfields in AVC to change, depending on which VC called it.
So here's the problem- how can I tell which view controller called the popup? It's basically the view that's below the popover. Currently I'm storing it as a variable but that's not ideal. I'm guessing it has something to do with the segue identifiers?
Any and all help much appreciated!
One approach to this is adding a property to your pop up view controller and then define the
prepareForSegue:sender:
method so you set your destination view controller's property to the sender of the segue.

What kind of view am I looking for?

I am creating a tableView on my iPad app where one of the cells has a UIButton titled "Edit notes". I would like a view to pop up over the screen containing a "textfield" and the keyboard, not a new view/push. Prefferably not even covering the whole screen. I guess I am looking for the view used when you have your iPad in landscape mode and you compose a new e-mail. A view popping up from beneath while you can still see the main view in the background.
I've been looking around, but I have no clue what to search for!
Here's an image of something like what I'm talking about, only I would need it to say "Save" instead of "Send" and without the "to/Cc/subject"-fields, and I guess I would require an NSString as return value. Any clues?
Or something similar!
This is called modal presentation style.
You can present any UIViewController or its subclasses.
Set the modalPresentationStyleproperty to UIModalPresentationFormSheetand present this viewController from an parent viewController (your tableViewController perhaps) with the presentViewController:animated:completition: method.
Take a look at the docs.
In Interface Builder, search for an object called "Container View". You can include whatever you want in this container and show/hide it when you need.

How do I create storyboard segue from a view controller to itself?

Is it possible to create a storyboard segue from a view controller to itself? I have a bunch of Entities that have Related Entities. I'd like to be able to display a Related Entity using the same view controller that's displaying the Entity. But I can't seem to create a segue that will display a new instance of the origin view controller.
Is it just not allowed? Thanks!
Well here's a solution that isn't quite the same but gets me what I want. I found it as an answer to this question.
The reason I thought I had to use a segue rather than the good old programmatic push of a view controller onto the navigation controller's stack is that I had set up the view controller's IBOutlets in the storyboard. I didn't realize that you could create a copy of the view controller as laid out in the storyboard without using a storyboard segue. You can! To see how to do it, check out that other question and up vote the answerer!
You can ctrl-click-drag (or right-click-drag) from an element (UIButton, etc.) to the containing view controller.
(Did you try this? I'm doing it right now; I have one stock UIViewController that just keeps adding itself indefinitely to the containing UINavigationController stack via a normal push segue.)
Yeah, it's annoying I can't do a 'manual' segue to itself.
What I did was added a UIButton to my view and gave it an action of push to the same view controller, and then made this button hidden. Then I can name the segue and reference it in the code.
Hacky, but works.

Resources