I am writing a job management app that allows users to post responses to a job and I'd like to use a textview similar to the iMessage style. Essentially a textbox at the bottom of the view that when focused moves up to sit on top of the keybaord and moves the view content up aswell, but also grows as the text is being typed in.
I have come across SlackTextViewController which exactly suits my needs, however there is one issue. I already have the job view setup (Storyboard and Objective c) and all I'd like to do is use the textview portion of SlackTextViewController to write responses in, however SlackTextViewController ships with it's own tableview built in etc so whenever I use the textview, the table lays over the top of everything else on the view.
Is there anyway to 'break off' just the textview portion and use that in a pre-existing UIViewController? Or does anybody know of any alternatives that would achieve what I'm after?
Related
As newbie, I finally got a case project for internship. Before jump in directly to code, I would like to ask about a logic.
here how it is look like
As you can as see, I have a search bar in the top, and under that a page view and under that a collectionview. So I will display to first 3 data in pageview and rest of it will be displayed in collectionView. Whenever user start typing in searchbar, PageView must disappear and collectionview must go all the way to the top. (under searchbar) And collectionview must display the filtered data. Once user delete all text from search bar, everything should be like in the beginning and pageview must be in the same page before user typed in searchbar. (If it was in the 2. page, it must be in the 2.page after its displayed again)
Problem is with hiding pageview when searchbar is used. My idea is the create ui programmaticly and once textDidChange func of searchBar runs, hide pageView and change constraints of collectionview programmatically. Once text is nil, make pageview visible again and change constraints again.
Is this logic useful? Is there any better way to do it?
Your approach seems correct to me, that's how I'd do it as well.
To add an extra touch, you can also animate the layout constraints changes (by calling layoutIfNeeded in the animation block, look up "animate constraints" on StackOverflow).
And for a perfect user experience, make those animations reversible by using UIViewPropertyAnimator so that if the user typed a letter and then quickly erased it during the animation it would just reverse in the middle. It's a somewhat advanced technique but you'll gain a great deal of experience with animations by implementing it. Watch Advanced Animations with UIKit from WWDC17 for more details.
I'm currently creating an update of my iOS application and I'm a bit stuck. I've tried to googling around but cannot find a decent answer on this.
I've a menu which links to different views. And I'm not really sure if I've done it the best method.
I've created a view, and added the links into a stack view. Should I considering changing it all to a tableview? or a collection view? Or maybe there's another way?
The current look:
Should I change this to a tableview? collection view? or something else? Or just let it stay as it is?
If the number of items in your menu changes at runtime and is large, you should use a table view, because a table view is good for efficiently displaying a screen's worth of items from a large list of items.
If the contents of your menu is small (under maybe two screenfuls of items) and fixed at compile time and you are using a storyboard, then you could use a table view with static cells, if you can make it look the way you want.
If the contents of your menu is small, then you can use a stack view (inside a scroll view) if that is easier for you. There is no particular advantage to using a table view over a stack view to display a small amount of content, unless you need other features of the table view (like the ability to select/deselect rows).
Based on the screen shot you posted, I'd either use a table view with static cells (since the screen shot is from a storyboard) or a stack view, depending on whether I can get the appearance I want from a table view. If, as in the screen shot, the buttons must be centered vertically, I'd use a stack view, because it's easier to vertically center the content with a stack view.
Look, the fact of have many itens on your screen is clear on the mobile applications, to make it easy, we have collecions view like UITableView and UICollectionView. On the UITableView's case, this implements the scrolling and have methods do handle the operations' list, you can see the documentation to check these methods: https://developer.apple.com/documentation/uikit/uitableview.
Main reasons to use UITableView
Implements scroll behavior.
Independent of size screen you can access all itens.
Easy to detect interactions like tap on cell.
Easy to make changes, like insert and remove content.
The UITableView exists precisely to solve problems like you has.
Both Instagram and Facebook allow their users to comment on news feeds. In the comment scene, they basically have a UITableView with all the comments and a “footer” where user may enter comments and post them. So the “footer” is a UIView or UIToolBar with a UITextField/UITextView and a UIButton. Truly simple stuff from the look of it. Well I have been trying to implement it and the keyboard is not cooperating. I need the keyboard to not hide the “footer”. Especially now in iOS 8 the keyboard comes with a suggestions tool bar that a user may choose to show or hide. All these interactions make it difficult to keep my “footer” right above the keyboard while user is entering text. Every time I think I nail the solution, I find a multitude of bugs.
In one implementation, I use keyboard notification to listen for when the keyboard is up or going down (partly based on iPhone Keyboard Covers UITextField). The problem with this implementation is that there is a lag of about 1 to 2 seconds for when the keyboard shows up and for the “footer” to climb to the top of the keyboard from the bottom of the screen. A second issue is when user drags the suggestion toolbar to either show or hide it while typing, it causes my “footer” to move in unpredictable manners: which means I will need some static variables to meticulously track cumulative interactions with the suggestion toolbar just to fix that bug. Also notice that I put “footer” within quotation marks. That’s because I am not referring to a UITableView footer. But rather a view that I create beneath the table view as suggested by UITableView, make footer stay at bottom of screen?
Another implementation I tried was to use a “footer” and a keyboard ToolBar. When user clicks on the UITextField of the footer, that would cause the keyboard to show up with a replica of the footer as inputAccessoryView. This is basically to visually fool the user into thinking it’s the same footer that seamlessly climbs with the keyboard. But in reality I am using two compound Views: a “footer” and a keyboard toolbar. The first problem I encounter with this one is that I cannot seem to make the tool bar text field the first responder programmatically. This actually used to work in ios-7. But since I updated to iOS-8 it does not work. So if I do footerTextField.inputAccessoryView=keyboardToolBar and then in the textfield delegate method check if(textField==footerTextField){[tooBarTextField becomeFirstResponder];}, iOS-8 just ignores the whole thing or, worse, dismiss the keyboard and the toolbar altogether, so that in fact the keyboard never shows up when I click on footerTextField since the showing and dismissing happen so quickly.So again this used to work in iOS-7, but in iOS-8 it does not work.
a third approach was to make the parent view a TPKeyboardAvoidingScrollView such that I would have parent, and children UITableView and “footer”. Here while TPKeyboardAvoiding have worked for me on other scenes in the app, for whatever reason it’s not working here. My guess is because I am using a UITableView as one of the children of a UIScrollView.
a forth approach was to make my “footer” an actual UITableView section footer; section footer because I want it to float at the bottom. The problem with section footer is that they don’t stick to the bottom, which gives a visually erratic user experience as you scroll the table.
Ok, so I have said a lot. So finally, has anyone implemented a scene similar to Facebook’s/Instagram’s NewsFeed Comment scene? If so, will you please help me?
To recap: the Facebook/Instagram input textfield grows with text; sticks to the top of the keyboard whether the keyboard's suggestion toolbar is showing or hidden; sticks to the bottom of the screen when the keyboard is gone.
SlackTextViewController seems to fit all your requirements and is very well-written.
I'd like to make a reader that behaves like Amazon's Kindle app. Specifically, I want to present a bunch of justified text in paragraphs, one column per page, and have it scroll between pages like the Kindle app does.
Let's assume I have the text in a simple format, like a text file per chapter, or even a string hard-coded in memory per chapter.
They're obviously using Core Text. Are they using a paged scroll view? Would that run in to memory problems for large books?
My initial thought is that they are using a UITextView to display a large amount of text, this kind of view allows you to add margin, padding, text and for iOS 6 you could use something like NSParagraphStyle to give styling to the text, the easy approach would be to create a really long text in different UITextViews within a UIScrollView and that would give you a nice result however if memory is a concern and the iOS version is not a problem I'd recommend using UICollectionViews, you can make each page a "cell" and then write some custom layout so when the user is scrolling the book you can actually just instanciate the page the user is using at a certain moment
The cool thing about NSCollectionView is that it behaves exactly like a UITableView so it's very memory efficient, something that is not on the screen is not displayed, and if it's going to be displayed then it's loaded.
hope this can give you some insight on the matter.
I ended up making something completely custom. It consists of 3 views, a left main and right view.
The view controller renders the text on the main view using Core Text, and calculates the size of the text frames (and therefore the number of pages) for each page in the current chapter.
If the user taps or drags right or left, the view controller will render one of the side views and let you drag it on. When you finish dragging or complete the tap action, it animates the pages into place, then swaps the main view with the one you dragged on.
The advantage to this method over using a UICollectionView is that it's very expensive to calculate the exact contents that should be displayed on a given page in a deterministic way, as a table/collection view would require. This way allows me to render the text of any chapter, and go back or forward lazily without laying out the whole book at once.
I need to display search results for my custom control and I'm not so sure what is the best way to make this configurable.
Basically the control is similar to the UITextField but with more visualization. When the user enters some text to the field, the control would enter full screen so that the search field is on top and the results are displayed beneath. This would be very similar way to address search in Apple's Mail.app (see the attached picture).
The issue here is what would the "full screen" mean on an iPhone. If the view is presented from a table view cell, the parent view's frame is not good. The window's bounds do not work as I want to keep the navigation bar visible if there is one. Also, the full screen would be different with the iPad. With the iPad, I think I could use the pop over.
I was thinking if the controller using my custom control would provide the bounds (a delegate method perhaps?) but that feels somewhat cumbersome.
Any ideas would be appreciated.
Update:
So far I've come to a conclusion that the iPad and iPhone versions of this have to have their own specializations of the results display. On an iPad, the popover is quite trivial to implement. On an iPhone, I really can't figure out the proper way to determine the bounds for the expanded control (the text field and results table).
It is hard to describe the problem, but all I'd really need is means to expand the control to occupy some bounds (in most cases the space between the keyboard and navigation bar).