I am not sure why there is so much white space on the top of UIScrollView. If I switch the tabs and come back to this tab again then everything is okay. See the image below:
How can I fix that?
UPDATE:
The constraints on the first UILabel which is the description are shown below:
The fix is to implement the following line of code after in the viewDidLoad;
self.automaticallyAdjustsScrollViewInsets = NO;
Related
I cannot scroll below that red line, it seems, that UIScrollView automatically cuts it out. How can I make it not cut it out?
contentView.translatesAutoresizingMaskIntoConstraints = true
This line seems to fix it, at least in my case. Content View is a child of Scroll View.
I have a ViewController with a view that contains a ScrollView and a PageControl positioned at the bottom.
What I noticed however, is that the ScrollView already has its own set of 3 dot indicators. So, just for the sake of testing, if I move around my PageControl bar, I can actually see two sets of dot indicators.
I have my IBOutlet set to my PageControl, so the dots get updated as I'd expect. However, the dots on the ScrollView don't change (and there are always 3 of them).
Why does the ScrollView already have its own dots? I tried unchecking "Show horizontal scrollers" but this did not get rid of the dots.
I guess why question is two-fold: How could I remove the dots from the ScrollView since I really only want the PageControl? Secondly, what is the purpose of having those dots on the ScrollView itself?
To be clear, I've already unchecked the Show horizontal and vertical scrollers in Interface Builder. I have also disabled them programatically:
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
Thank you in advance!
The UIScrollView does not have dots. Maybe you added two UIPageControls accidentally. If you show more code maybe we can help but all I can tell you is that a UIScrollView is not the source of the dots.
I'm trying to set the height of a UITextView from a UIViewController's viewWillAppear event, here's the code:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
textView.text = blah blah...
textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y,
textView.frame.size.width, textView.frame.size.height-20);
}
However, it seems to ignore my sizing, it's as though after this event is called, the textview is resized by something else.
What am i doing wrong? Is there some good way to do this?
Thanks
-edit-
Got it working by putting the code in my viewDidAppear instead of the viewWillAppear.
So it works now.
Although i'm puzzled why i need to do this (remove 20 pixels from the bottom) - i mean shouldn't it resize to fill automatically? Why is it resizing to 20px too long? There's a tab bar at the bottom and a nav bar up the top. Is that confusing it?
Simple but obvious question, does the text change, in other words, is the outlet hooked up in IB?
JUSTA TIP: Look at using the helper functions for CGRect such as:
textView.frame = CGRectInset(textView.frame, 0, 20);
In an app with just this code and a single TextView the resizing occurs as expected. So..it's definitely something else in your app.
Are you maybe referencing the contentsize property or something else in your viewDidAppear?
Got it working by putting the code in my viewDidAppear instead of the viewWillAppear.
So it works now.
Although i'm puzzled why i need to do this (remove 20 pixels from the bottom) - i mean shouldn't it resize to fill automatically? Why is it resizing to 20px too long? There's a tab bar at the bottom and a nav bar up the top.
I've got this strange bug in my app. I'm making a subview and drawing it over the top of my main view. To get rid of it I'd just hide it. Here's the problem: There I can see part of the view underneath peeking through the bottom in a line that seems to be the same size as the status bar. I've put how I'm adding my subview below, along with a screenshot to illustrate my problem.
theLaunch = [[firstLaunch alloc] init];
[window addSubview:theLaunch.view]; // it goes on top
[window makeKeyAndVisible];
Here's the screenshot...the view underneath is grey.
It looks like you don't have subview properly 'anchored'. If in IB, then you could try attaching subview to bottom edge of containing view. Your 'main view' seems to be stretching to accommodate available space (which is changed by presence of status bar), while you 'sub view' appears to be positioned (0,0). Something like this might help:
Programmatically, you could use UIView's autoresizingMask. Something like:
theLaunch.view.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
How confident am I that this is the actual problem? Not as confident as I would like to be.
Where are you defining your user interface for firstLaunch? If it's in a nib file, you need to have theLaunch = [[firstLaunch alloc] initWithNibName:#"firstLaunch" bundle:nil];. If you are manually adding your interface elements; where are you doing that? If you're adding them manually in ViewDidLoad, I think you should be seeing it.
Your image probably has alpha transparency in the places where the image below shows through. If you don't want that effect, you should recreate the image without alphas (fully-opaque).
If you aren't able to recreate the image for some reason, you could try either setting the opaque property of the image view to YES (I'm not sure if that will work), or adding another view below your image view that is opaque and has a solid background color that isn't transparent.
I have a UIScrollView with with different view controllers for each page inside it. When I use setContentOffset:animated: to scroll to a different page I can see a white line between the pages. This white line doesn't appear when I scroll by dragging the UIScrollView.
Has anyone seen this problem before? Any idea of what I might be doing wrong?
Thanks!
Setting all of your backgrounds (as in all layers deep) to magenta is a good test, but you may find that doesn't help. I have the same bug, but everything I have is black. The white line is there scrolling some directions.