I have got a tableViewController with one section and one cell.
How can I get the height between the navBar and the keyboard without any toolbar above it?
I tried this code: self.view.bounds.size.height
but I get the height of the entire view down the navBar...
I'd like to get this size to assign it to the cell and to the textView inside it.
Thanks :)
You can't get the height of the keyboard until it is displayed. You'll need to register for one of the keyboard notifications and then check the UIKeyboardFrameEndUserInfoKey value. This will give you the frame for the keyboard. Use this to adjust the height of your view.
I don't know what happens if you change the rowHeight property on a table that's already displayed, but my guess is that it should do what you want, once you compute the height to set it to.
Related
I have two UITextView inside a UIScrollView and the TextView can resize as the user types more text into them. I need the page to be scrollable to account for this so I put them in a ScrollView, however the height of the ContentView doesn't change with the TextViews. Here's what I tried so far:
adding a bottom constraint from the last helper text to the bottom of
the content view with priority 1000 and constant 210. This doesn't
work because the section will be scrollable before the TextViews get
taller and on tablets or larger devices it will make my first
TextView taller.
adding a bottom constraint with a constant of 210 or lower will give me a layout error.
I also thought about calculating the height of the content view and maybe adjusting the constraint based on that but this doesn't work either.
Here is a link to the file in question: https://www.dropbox.com/s/g7q1lbj0pxx14jh/Main.storyboard?dl=0
Any suggestions?
It's also worth noting that the keyboard will cover the second TextView when the first one gets too big so I will eventually need to edit that constraint based on the height of the first TextView (to give it more padding at the bottom so that the user can bring the second TextView in view.
Here is the fixed variant https://www.dropbox.com/s/gujry7ngziaipm7/Main.storyboard?dl=0
I found just 1 error:
You forgot to specify bottom offset from last view in View Container which is UILabel - "Being clear...", so your view container doesn't know when to resize as soon as you do not specified all offsets to it.
I'd like to resize my app components when device is turned into left or right side - when it keep horizontal position
I'm checking device rotation in willRotateToInterfaceOrientation event and then I have to change width of searchBar and tableView. How should I do it? I tried some variants with components .frame and with CGRect, nothing works.
Update:
it can be done without any code. View my answer below
If you laid out your elements in Interface Builder then you can just add an outlet to the width constraint of your search bar. Then, change the constraint's constant property to change the bar's width.
I found the way to do I need
So, the task is that components will be resized in width when device turns horizontally.
1) Select items must be resized
2) Select "Leading Space to SuperView"
3) Without unselection, select "Add missing Constraints"
That's it. Now they will be resized correctly
I've a problem with my view in iOS7 with autolayout.
This is my structure:
The UITextView content is dynamic so I fit his contentSize dynamically in the viewDidLoad.
In my viewDidAppear I try to fit the contentSize of the MainScroll and the mother view calculated by the sum of UIScrollView height (the little one), Pager height and UITextView height. I logged this height and it returned the correct size: 1300px but the view doesn't scroll.
If I change tab and return here the scroll start to scroll, I've tried to put every piece of code in the viewDidLoad but it doesn't work.
Can you help me?
Thanks and sorry for bad English.
Try selecting it and then selecting "reset to suggested constraints" in the storyboard. :).
What's the correct way to autosize or automove all view's components when call status bar appear (status bar height change)?
I'm using:
- (void) application:(UIApplication*)application
didChangeStatusBarFrame:(CGRect)oldStatusBarFrame { }
but in this way i need to set manually the frame of all the elements. I think that not is the best way.
I tried to set autosize in interface builder panel, but nothing change when status bar change frame.
Is there a correct way to do this in all of my view without set frame to every elements in every view?
thanks.
Using - (void) application:(UIApplication*)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame is not a good place to do this.
The solution will depend on your desired layout. If it is simple enough the autosizing mask will work fine. For more complex layout you might want to subclass UIView and use it as a container for the subviews. You can then override layoutSubviews to perform the correct layout depending on the bounds of the view (with the container being autoresized).
For autoresizing: e.g. If you want to have all labels to be fixed with respect to the bottom border and have a fixed height: simply click the bottom spacing in the autoresizing dialogue and remove the height arrow.
It might be a silly question.
I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView.
However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No.
It would be perfect if a scroll indicator of UITextView appears outside UITextView.
In the attached picture, let's say the red box represents the entire UITextView. I tried to change UITextView's scrollIndicatorInsets property, but a scroll indicator can be moved only inward to be visible.
Several apps such as Pages, aWriter, Plaintext achieve this feature.
Could you give any suggestion?
Thank you!
I
You can set the scroller right inset value of the UITextView to negative value and disable the clip subview option to achieve your require. No other scrollview is needed.
Alternatively you could set the Right contentInset property.
UIEdgeInsets insets = textView.scrollIndicatorInsets;
insets.right += 5; //add what ever is your margain
textView.scrollIndicatorInsets = insets;