Debug untouchable UIButton - ios

I have a really strange problem on my App.
The issue is that:
The UIButton inside an UIView used as Footer in a UITableView respond correctly to touch only for the half of the height.
No views are over the UIButton.
I drawn a red line on the touchable part:
And this is the Debug View Hierarchy

Is this a UITableViewCell? It looks like the content view's frame isn't as big as the cell's frame. Maybe the bottom constraint of the button is set to the cell's bottom rather than the cell's content view's bottom.

Related

Can't build UIScrollView with Autolayout properly

Can't build content inside scroll view with autolayout. Yes, I've investigated a lot, read apple technical note and some articles, I know, that content view should be constrained with scroll view's superview but can't still achieve the desired result. I expect this result:
fixed or scrollable (for small screens) portrait mode
always scrollable landscape mode, not to loose or overlap my fixed content
my button (red view) should always be at the bottom
my photo (yellow view) should always be fixed size and not to loose content
(like in my wrong landscape mode)
Making this work is actually pretty easy. All you have to do are the following steps:
Add the UIScrollView as subview of your UIViewController`
Add the UIView as a subview of the UIScrollView
Add the UIButton as a subview of the UIViewController. Do not add it as a subview of the UIScrollView if you want it to stick to the bottom.
Then add the following constraints:
Pin the UIScrollView to the top, left and right of you UIViewControllers view
Pin the UIButtonto the left, right and bottom of your UIViewControllers view
Pin the UIButton top to the UIScrollView bottom
Pin the UIImageView top, horizontalCenter and bottom to the UIScrollView
Set the UIImageView height and width constraints
Set the UIButton height constraint
And that's it. Do not add anything to the UIScrollView contentView and do not set the contentSize programmatically! The contentSize ist set automatically by Auto Layout.
Here are screenshots of the constraints and the result:

iOS: dynamic height UIScrollview autolayout

I making a article detail view like Facebook.
This view have content(profile image, writer, date, content text) and comment write view.
So Top view is UIScrollview, Bottom view is UIView.
UIScrollView have UIImageview, UILabel*3,
UIView have UITextView, UIButton.
When touch UITextView in UIView, the keyboard comes up.
So UIScrollview will be smaller and UIView position will be moved.
And User will write text, UITextView line will be added so UIView Size will be extended.
Eventually UIScrollview and UIView height not Determinate.
How to set autolayout this view?
Instead of having UIView for textView and button, what i would suggest you is, just add one scrollView set its constraints as below
Then add a UIView as container view inside scroll view, (select scroll view go to Editor, select Embed In, and select View) and set its constraint as below
Now add your imageView, labels, textView and button one by one, and make sure your set imageView's top space to view and button's (which is at the bottom of screen) bottom space to view, and all other view's top space and bottom space to their nearest views, this way scroll view can easily determine the height required for it.
One last thing, when user click inside textView you might need to move scrollView upward in order to make textView visible to user while he is typing, to do this one easy solution is just download the library 'TPKeyboardAvoiding' from here add all classes to your project and once done, set your scrollView's custom class to 'TPKeyboardAvoidingScrollView'. Clean and run the project, it should work..
May try it:
What I say below is about constraint:
UIScrollView top, left, right equal self.view top, left, right
UIScrollView bottom equal UIView bottom
UIView left, right, bottom equal self.view left, right, bottom UIView height equal 200(you set it)
OK, when you UITextView is touched, set the UIView height constraint to what you want(maybe 300)
I think it works!

With Storyboards only, how do I create a UITableViewCell that can scroll left and right using UIScrollView?

Similar to Mail.app where you can scroll the cells side to side, I want to be able to do it in my app using Storyboards and UIScrollView with my UITableViewCell.
I add some buttons to the contentView of my cell, and then UIScrollView with an embedded UIView on top of that to contain the main portion of the cell. I then add a label to that.
I understand that scroll views in Storyboard work by specifying constraints to show what the contentSize of the scroll view should be.
So I position the UIView in the UIScrollView to be the same width and height of the scroll view, but give it a trailing constraint of say 50pt to allow the scroll view to scroll. When I run it I can then move the cell to the left to reveal the buttons.
But to get it work in the other direction I have no idea. If I add a leading constraint it actually moves the cell to begin with away from the left, offsetting the cell to begin with when it should be left to the user to scroll it. It works fine other than initially being pushed over.
I created a sample project showing it here: http://cl.ly/2i3m1W2T0i3C
Like I said I just can't seem to figure out how to get it to scroll in both directions.
Try setting the contentView of the scrollView with width higher than the scrollView itself.
Something like:
Assuming your scrollView.frame is (0,0,100,100)
[scrollView setContentSize:CGSizeMake(300,100)];
place your table view, let a part of your view out of the screen and check that case:

Autolayout with UITableView

My UIViewController contains a UITableView (is always on top, the same width with the superview), and a UITextView (is always under the UITableView 10.0f), as below:
Now I want to use autolayout to raise up the UITextView when the keyboard appears. I add the following constraints for UITableView (sticks to the top, and is always on top of UITextView 10.0f):
UITableView : Width (320), Height (706), Left, Right, Top, Bottom (10.0f)
UITextView : Width (280), Height (44), Left, Right
I assign IBOutlet the UITableView's height constraint, and modify its value in code. For example, when the keyboard appears, the height of UITableView will be decreased -216.0f (the height of the keyboard), and as a result, the UITextView will be raised up on top of the keyboard (because the UITextView is always under the UITableView 10.0f).
So, that's what I expected. However, for the only first step, when running application, the UITableView takes up the whole screen, and I do not see my UITextView. Is there any problem with my constraints?
the keyboards default behaviour is to cover the screen, autolayout cant account for it since its not part of your layout originally, i wrote a category that will provide this functionality for you here, just #import it into your viewController and it should just work

Why is my UIView within UIScrollView not scrolling?

I'm trying to setup a scroll for a UIView within a UIScrollView.
My view hierarchy is:
UIView (Controller) > UIScrollView > UIView (I'll call this subView from this point on)
I have used the IB to set the layout. I set the top of the subView to be inline with the top of the UIScrollView frame. The subView is as wide as the UIScrollView frame and extends beyond the height of the UIScrollView frame.
In the subView I have UILabels (also set up using the IB). To test the scrolling, I have one label that is just peeking above the bottom border of the UIScrollView frame. When I run the app this label would ideally be able to scroll into view, however, there is no scrolling and the label is just appearing as being cut off where the UIScrollView frame ends.
In the ViewController.m I have the following:
- (void)viewDidLoad
{
self.scrollView.contentSize = self.scrollSubView.frame.size;
}
where scrollSubView is the UIView within the UIScrollView.
What am I missing (doing incorrectly) that is preventing the scroll from working?
Thanks for any assistance offered.
Possible Issue
Autolayout is on, and it won't let scrollview work as required.
Possible Solution
Check for autolayout of storyboard and untick it.
If you dont want to set it to off, you can follow this short video
which is wonderfull to deal scrolling with autolayout. :)
UIScrollView with autolayout on

Resources