UITextView does not display - ios

There is a UITextView (green) inside a UIScrollView that should be displaying some text, but does not.
The frame of the ext view looks correct and has a width and height greater than 0. Any idea of what is going on?
"<AppName.UITextView: 0x7fd1ff810800; baseClass = UITextView; frame = (560 160; 23840 80); text = \'This text should appear\nT...\'; gestureRecognizers = <NSArray: 0x600001b9a520>; layer = <CALayer: 0x6000015a48c0>; contentOffset: {0, 0}; contentSize: {23840, 48}; adjustedContentInset: {0, 0, 0, 0}>"

What is peculiar about the UITextView is that it is very wide, over 23000 points wide. I tried a not so wide version of the same view, 500 points wide, and placed it right under the buggy view... it worked.
To solve the issue I changed the view hierarchy (UITextView within a standard UIView) so that the text views have a maximum width of 500 pts and it's working.
Possible root cause: The UITextView either wasn't designed to draw itself with extremely large widths or there are some technical limitations that prevent it from doing so.

Related

Swift UICollectionViewLayout contentSize crash

Trying to adjust the content size of a collection view on 4" screens in iOS and I'm getting an error in the console about the width using collection view flow layout.
if DeviceType.IS_4_INCH {
collectionView.contentSize = CGSize(width: screenWidth - 50, height: collectionView.collectionViewLayout.collectionViewContentSize.height)
}
Error:
The relevant UICollectionViewFlowLayout instance is
<UICollectionViewFlowLayout: 0x7fbb9144dd20>, and it is attached to
<UICollectionView: 0x7fbb92885800; frame = (10 10; 270 750); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fbb914d25e0>; layer = <CALayer: 0x7fbb9147f560>; contentOffset: {0, 0}; contentSize: {325, 750}> collection view layout:
<UICollectionViewFlowLayout: 0x7fbb9144dd20>.
I see the issue is relating to content size (325) when the frame is 270 but when I try to change it based on the screen width it crashes.
Thanks
Looks like one of your elements exceeds the size of your UICollectionView after you resize frame
Try invalidating the current layout before reloading your data:
self.collectionView.collectionViewLayout.invalidateLayout()

UIScrollView zooming on incorrect point

I have a UIScrollView with an image, and the image is in a container view. The view hierarchy looks like this:
UIScrollView
UIView
UIImageView
Panning works fine, but when I use the pinch gesture to zoom, the image changes size, but doesn't move relative to the origin, so the point centred underneath the two fingers moves as the gesture progresses. This makes it very difficult to zoom in on a particular point, since it's sliding away as you're zooming.
Description of the views involved:
<MyApp.MyView: 0x7ff6fd827e00; baseClass = UIScrollView; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x61800004a4d0>; layer = <CALayer: 0x618000023420>; contentOffset: {684, 487.5}; contentSize: {1731.4584832023011, 1154.3056554682007}>
<UIView: 0x7ff6fbe0c4d0; frame = (0 0; 1728 1152); transform = [2.2028669620902912, 0, 0, 2.2028669620902912, 0, 0]; layer = <CALayer: 0x6180000234c0>>
<UIImageView: 0x7ff6fbe09cd0; frame = (0 0; 1728 1152); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x618000023340>>
I have the UIImageView inside the UIView wrapper because I will have other views overlaid on the image which need to zoom/scale with the image.
There's very little of my own code running during the zoom. The UIScrollViewDelegate returns the UIView (the parent of the UIImageView), and configure the scroll view:
minimumZoomScale = 0.2
maximumZoomScale = 3.0
contentSize = image.size
Well, I've made a simple project that use your structure of views. And I didn't face with the problems. Possibly, you should check this things:are auto layout constraints setting right way is your parent view zooming correctly is mode of UIImageView fitting your needs Hope this may help

UITableViewCell.contentView reports wrong width

How is this possible?
(lldb) po contentView
<UITableViewCellContentView: 0x7fd0f3470c90; frame = (0 0; 400 699.5); opaque = NO; gestureRecognizers = <NSArray: 0x7fd0f346c980>; layer = <CALayer: 0x7fd0f3461930>>
(lldb) po UIScreen.mainScreen().bounds
origin=(x=0, y=0) size=(width=320, height=568)
Screen has 320px width but an empty custom table cell has 400.
Incase someone bumps into this, the culprit was the tableview. When I pinned it's edges to the superview, the cells started to work correctly.

UIImageView using UIViewContentModeScaleAspectFit in ScrollView is not center

Thanks a lot! Please help!
I hava a scrollView in a UIView and a imageView in the ScrollView.
they have same size.
and here are the LOGs of the scrollView and imageview
and I have not used autoLayout constrains between uiview and scroll View
as well as scrollview and UIimageView
the code are:
- (void)setupScrollView
{
CGRect frame = CGRectMake(0, 0, self.scrollViewSizeView.frame.size.width, self.scrollViewSizeView.frame.size.height);
_colorScrollView = [[ColorScrollView alloc]initWithFrame:frame andUIImage:self.image];
[self.scrollViewSizeView addSubview:self.colorScrollView];
}
- (instancetype)initWithFrame:(CGRect)frame andUIImage:(UIImage *)image
{
self = [super initWithFrame:frame];
if (self)
{
self.contentSize = frame.size;
_imageView = [[ColorImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
self.imageView.image = image;
[self addSubview:self.imageView];
}
return self;
}
scrollView:
<ColorScrollView: 0x7fee13746dc0; baseClass = UIScrollView; frame = (0 0; 600 436); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fee13748270>; layer = <CALayer: 0x7fee13741330>; contentOffset: {0, 0}; contentSize: {600, 436}>
imageView:
<ColorImageView: 0x7fee13747e00; baseClass = UIImageView; frame = (0 0; 600 436); opaque = NO; layer = <CALayer: 0x7fee1370fc50>>
the imageView content mode is UIViewContentModeScaleAspectFit.
I want the image in imageView is center.
but it is not.
it look like it prefer to stay at the right side.
sorry that I don't have enough reputation to post a image:
it looks this (* means transparent)
*****this is the image area
*****this is the image area
*****this is the image area
*****this is the image area
*****this is the image area
The only thing that come to my mind is add a uiview in the uiscrollview and then add your image in to that uiview
if you could give us some of your constraint you use that could help us
From your commends for #Ali RP's answer, "if the aspect ratio of the image is close to the aspect ratio of the imageView. then no problem." I think your problem is because of UIViewContentModeScaleAspectFit. You have some white space of both size of the image.
UIViewContentModeScaleAspectFit
Scales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.
And the reason why it is not centred is because the image you are using is too big I guess and right part of the subview is cropped. Try with a smaller one and one with different aspect ratio for debugging. For example, you should have some images with width > height and some with height > width.
Also see this one:
Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

Frame shifted incorrectly with Autoresizing in iOS7

I'm having an issue with a view using autosizing resizing improperly in iOS7 (but fine in 6). The view initially renders as I'd expect, then I push another view onto the stack. Once I pop back to the original view, a subview that should be anchored on the right sizes itself too large and of the bounds of the superview.
It's a fairly simple view, created in a Storyboard, that includes the following hierarchy:
Scrollview -> View ->ImageView
It uses autosizing masks, which frankly was done because I had issues using autolayout inside the scrollview in this case (don't want to get into that here). The mask for the ImageView is pretty simple:
-
|
_
|-|<->|-|
-
|
-
On initial load, the X coord and width are as follows:
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H;
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 110; 280 50); clipsToBounds = YES; opaque =
NO; autoresize = W;
On subsequent load, it appears as follows
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 160; 320 50); clipsToBounds = YES; opaque
= NO; autoresize = W
The notable difference being, as bolded, the width of the ImageView frame increases to 320, which is the size of it's bounds. Since it is still offset by 20, it ends up running off the screen. Obviously, I would expect it to stay at 280, as it does when this same thing is run in iOS6.
I don't manipulate the view in any way in code, so this should all be tied the autolayout masks. I cannot find anything about others having similar issues.
--

Resources