Resize an UIView that contains a TextView - ios

Is there a way to insert a TextView inside a customized UIView and then resize the UIView based on the number of lines in the TextView? Something that looks like the message bubbles from the Message app (I believe they are also cells).

This is a git project by Alex Barinov that achieves what you are looking to do with a UITableView. Using a table view, you are easily able to dynamically add next chat "bubbles" to the bottom of the screen and push the old content up.
http://alexbarinov.github.com/UIBubbleTableView/

Related

iOS 13 Voice Control UIScrollView

The iOS13 Voice Control feature has a command 'Scroll Down'. This command works for UITableViews but does not seem to work for UIScrollViews with scrollable content.
Is this intended?
Intended or not, is there a way to enable this command to work on a UIScrollView?
Example: a UILabel with a lot of text inside a UIScrollView (constraints are correct - it scrolls and is acknowledged by Voice Over saying 'Page 1 of 3' when active)
This command works for UITableViews but does not seem to work for UIScrollViews with scrollable content.
... only if this content is a huge UILabel content that must be scrollable: add many other elements (sliders, buttons...) and you'll notice that scrolling is enabled.
About that, in the TextKit Best Practices (2018 WWDC video), it's highly recommended to use a UITextView for this purpose:
Is there a way to enable this command to work on a UIScrollView?
Switch the label and your scroll view for a text view instead to make the Voice Control feature work with your specific use case.
Otherwise, it works with many other elements different from UILabel: the scroll view knows its content size and when it has to scroll down/up but the Voice Control feature doesn't recognize the label content as an element to directly interact with inside a scroll view.
I tested with a button and a huge UILabel as you did:
Scroll down that worked to reach the end of my label.
Scroll up that never works.
The label seems to be a kind of empty box that Voice Control ignores in a scroll view: to enable this command in a scroll view, just replace your label by a text view.
Now, if your use case is a single UILabel in a UIScrollView, remove them to display a UITextView instead.
EDIT
Here's the Xcode screenshot to make the UITextView scrolling work with the VoiceControl feature:
... with the results hereunder:
As you can notice, this is just a blank project with a simple text view: iOS recognizes this single element and acts as desired when Scroll down and Scroll up are vocalized.

Expandable view and text

I'm trying to create an iOS app and I want something like the pics below which when I tap the down arrow, the text and view expand.
I have no idea how it would be possible or even what should I call it.
Expanded one:
Edit:
StoryBoard:
There is a view for Video player top and a ScrollView down which contains an image and a tableview. what i want is that put the above feature(2 pics above) instead of that image. and scroll all image and tableview up to be behind of video player view
Using Autolaout you extend the height of your textview based on content size and your view
You need self sizing cell with tableview automatic dimension you can find tutorial for that
in label set number of lines 2 and line break mode to truncate tail initially ,
on tap of button action you need to set number of line 0 and line break mode world wrap , and use beginUpdate and endUpdate tableview
You have to add action (selector) to the button and in it you have to modify the frame and properties of containting view. Please post some code/storyboard for detailed answer.

UIViewController with UITableView and TextField storyboard placement

This might be a simple question but using storyboard I can't seem to position my table, a message field and a button correctly. In the picture below, if it's positioned that way, only then do I get to see the text field and button at the bottom of the screen and the table view takes up the rest of the screen. If I drag the text field and button to the bottom and resize the table, the text field and button disappear and the table is cut off. Why is that? Is there a solution to this without doing it programmatically?
Easy solution is to remove all constraints then position them where you want them.
You'll find you get different effect when try to reposition items depending where you drag from for example double tap an item and nudge it with arrow keys or grab the middle to move it resizing via the corners.
But in my opinion it's easier remove all constraints from the view and then set them as you go.
Also you might want to consider using a container view for the table view and have a separate UItableViewController that way you can easily separate out that the tableview logic from the other ViewController. It will help stop things getting a little messy later on as project grows.

Xcode 6.1 IOS really long form

I am quite new to xcode.
I am trying to create a contact details form for an iPhone using the storyboard. The problem is that form is longer than the display and I can't work out how to design it using the storyboard.
Any ideas?
Tom
In IB, you can set the controller's size in Simulated Metrics to Freeform, then select the view and make it as tall as you want. Then, add a scroll view to take up the whole view, and add your UIElements, and lay them out how you want. When you run the app, the view controller will still only be as big as the screen (obviously), but the scroll view will be as big as you made the view in IB (you may need to increase its contentSize even more to be able to scroll to the bottom).
Such forms are often made in storyboards using a UITableView and setting the "content" of the table to be "Static Cells." You can set any number of cells and the contents of the cell you want. The table itself is scrollable inside the storyboard/Interface Builder editor and looks much the way it would when presented to a user.
First, select the tableView on the left
Then, you can move it simply scrolling (on mac, two fingers on the trackpad, or using the mouse wheel)
You should have a look at UIScrollView, it is designed to support content larger than screen size (like you see in web browser or settings)
Basic usage is:
//Set a size which will be able to cover all form elements
[yourScrollView setContentSize:CGSizeMake()];
//Your scrollView now extends from CGPoint 0,0 to contentSize.width,contentSize.height.
//Your subviews should be positioned according to scrollview's bounds not the viewcontroller.view or any other container view.
//Add all the form elements
[yourScrollView addSubview:...];
[yourScrollView setDelegate:self]; //If you need actions after user scrolled etc.
Have a look at the developer manual for more info. Most method names are quite self explanatory.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html

How to ensure that only a certain section of a UIScrollView appears to slide?

I use a UIScrollView that has horizontal sliding enabled.
The Heading of the scroll view is Instructions for Using this App
And below that, I have instructions, one instruction per "page".
When the user scrolls horizontally, new instructions show. However, during this horizontal scrolling, the "Instructions for Using this App" from the second page also appears to move.
Instructions for Using this App <--- I do not want this to appear to slide
1. Instruction number 1. XYZ...
more text more text more text
more text more text more text <--- I want only this to slide
How to achieve this?
You can place separate UIView (probably UILabel in your case) on top of your UIScrollView, so your UI hierarchy will be something like:
UIView (screen)
UILabel (header)
UIScrollView (scrolled content)

Resources