iOS 7 - UITextField Clip Subviews Isn't Working - ios

I am porting an iOS 6 application to iOS 7 and have noticed some UI bugs that I have bad some issues solving. The largest would be one I found in the UITextView. In iOS 6 I have a UITextField that has a varying amount of dynamic text in it. I have a function that resizes the table view cell around the text view but I found it hard to accurately predict the size of the UITextView so I just disabled clipping and let the text overflow outside the UITextView. I put a buffer between the cell view and the text and thought the problem was solved. When I ported the application to iOS 7 this no longer worked. I can't seem to find a way to have the UITextView not clip it's subviews and overflow the text as it did in iOS 6. I have tried setting setClipsToBounds:NO both in the UIStoryboard and programatically, and have also tried disabling the layer mask with setMasksToBounds:NO. Nothing seems to work, how can I solve this problem?

Hey so I ended up fixing this issue using the iOS 7 constraints. I clipped the bottom of the UITextView to the outer view and removed the pinned height. This allowed the UITextView to resize appropriately.

Related

Is there is UITapGesture size limit between regular and plus sized iPhones

I am adding a UITapGesture to a UILabel in my code.
What is confusing me, when I run the code on an iPhone 7/8 on Hardware or in the Simulator, the TapGesture isn't called. However if I run the exact same code on an iPhone 7/8 PLUS on Hardware or in the Simulator the UITapGesture is fired.
Is there some sort of size limit to touch sizes which is causing this, and how do I get around it?
I have double checked the User Interaction is selected in Xcode.
let myTap = UITapGestureRecognizer(target: self, action: #selector(myAction))
myLabel.addGestureRecognizer(myTap)
This is how I am adding the tap.
DonMag, Matt, and Michael all ended up being part of the winner.
OK basically my views were in a view that were in a segment of a stack view.
Basically the Autolayout was NOT adjusting the superview's height that held all the children views which had the GestureRecognizers. So even thought the labels were still visible, they weren't receiving the Gestures because they were outside the bounds of the parents. But was what was weird is this only happened on 7 and 8 and on 7 Plus and 8 Plus. So basically added a constraint to set the container view's height equal to the stack views height (forcing Autolayout to readjust everything for 7/8 and that seemed to do the trick).
Super annoying, but thanks for the suggestion guys, it was appreciated.
ALso switched to the view storyboards in 7 was a help.

iOS 9.1 UIScrollView leaving blank space

I have a ViewController with a hierarchy as follows:
UIViewController
UIView
UIScrollView
UIView
UIImageView
UILabel
The layout is such that the UIScrollView fills the screen. There is no extra logic executed on this ViewController, such as programatic scrolling, listening to scrolling, etc.
When I run this on an iOS 9.0 simulator, the layout is correctly inflated, with the UIImageView drawn flush against the top margin.
But when I run this on an iOS 9.1 simulator, there is initially a large whitespace between the top margin and the image. Upon touching the UIScrollView it corrects itself, scrolling that the UIImageView is flush against the margin.
Setting automaticallyAdjustsScrollViewInsets does not have an effect (presumably because the scrollview isn't at my root).
My question is: What is different about iOS 9.1 scrollviews that it would be causing this, and what is the work around? Its bothering me since this isn't exactly a complex layout I'm trying to use.
Edit
Screen shot of my hierarchy and the constraints applied to them, maybe it helps.
I think the issue might be the hight constraints. try getting rid of them and add them back in, one at a time as needed.

UITableView rendering differences between iOS 6 and iOS 8

I am in the process of updating an old app from XCode 4.6 to 6.3 and have run into a difference in how my custom table view cells are rendered between iOS 6 and iOS 8 (well the change can be seen in iOS 7 as well).
Here are 2 screen shots from Xcode 4.6/iOS 6.1 simulator:
Here are the equivalent Xcode 6.3/iOS 8.1 simulator:
(As background, the Preferences screen is a grouped UITableView with 3 groups and 1 element per group. The Units screen is a single sectioned UITableView with 3 elements. And the "Note" on the Units image is just a plain view)
The difference I didn't expect (and don't like) is that in iOS 8, the custom table cells have expanded horizontally to cover the entire width of the screen, and have also lost their rounded corners.
I have been looking around to see if/how I can make the iOS 8.1 version look more like the 6.1 version, but so far have failed.
Is it possible to easily get back the layout I want? And if so, where should I be looking to make changes?
One possible approach is to set tableView.backgroundColor and your custom cell's contentView.backgroundColor to clearColor (it can be done via the interface builder as well). Then add a background view to your custom cell. You can give it rounded corners and add space around it.
This is what it looks like at runtime (the blue background belongs to the view behind a tableView):
This is more tricky though when we deal with a group of cells on your right screenshot. There the first cell has to have rounded corners at the top, the last one has to have rounded corners at the bottom, and the middle one shouldn't have rounded corners. I guess, it can be done (you could take indexPath into account when configuring the cell), but it takes a bit more work.
P.S. I'm sorry for the size of images. I don't know how to restrict it.

UIScrollView zooming only to the size of UIImageView

I have UIScrollView in which UIImageView is held like on the screenshot:
My problem appears when I zoom and instead of being able to scroll only in the area of my image (subview of scroll view) I'm able to scroll around the original size so I get a lot of white space around my image which isn't what I want. You can see what happens on the screenshot below:
I wonder what should I update to keep my scrolling area only the size of the image?
After some research, some trials and errors I've finally achieved what I was planning to do.
First of all, I wanted to use only autolayout with IB which sure can be done but with some effort. After some digging I've found this technical note which by "Pure Auto Layout Approach" understands adding contraints in code but I was aiming at only IB which led me to this simple but beautiful solution called ios-imagescroll. After investigating this code with joy that I've finally found solution I came with some error but only on iOS 8 devices... iOS 7 worked like charm out of the box.
I assume that due to big changes in iOS 8 autolayout is more strict and you must be 100% sure what you want to accomplish. It turned out that this slight change MATTERS on iOS 8:
Of course, this bug, fix (call it whatever you like) was fixed by experimenting with everything but I guess that UIScrollView's content view (in that case UIImageView) must be the first item in constraint.
[yourScrollView setContentSize:CGSizeMake(yourScrollView.size.width, yourImage.frame.origin.y + yourImage.frame.size.height+35 )]; //let's say just 35 ...
yourImage may have x,y origins like (0,0) [I see a lot of space above it, so I assume you have set other values for x,y]

Text is not fully displayed in UITextView

My UITextView is being very weird.
To explain the problem, the UITextView is placed in an UITableViewCell, and at the first display, the second line is missing :
If I continue scrolling down, and go back to see this UITextView, everything is back to normal:
What is very weird, is that if I set my UITextView as none selectable (what I want in fact), the text is well displayed, but the font is lost :
It seems that I have the same problem described here:
UITextView - setting font not working with iOS 6 on XCode 5
and the fix given (setting the UITextView as Selectable) worked fine for the font. But this problem with the cropped text makes this solution inadequate.
The UITextView has a red background color to be sure that the size is ok.
Everything is done in a Storyboard, but I also tried to set the font manually, the problem is still there.
Have you any hint of what could be wrong?
You can use AutoLayout to adjust the UITextView size inside the cell or you can use
[cell.textView sizeToFit];
I recommend using AutoLayout as it shouldn't harm the performance so much.

Resources