I have a horizontal ScrollView (Height 150) at the top of my UIViewController. The ScrollView contains a number of UIViews (80 x 125), with each UIView containing a 64 x 64 UIImageView.
The issue I am having is dragging the UIImageView into my main UIViewController (UIView Screen).
Whenever I click and drag the image, it is hidden within the ScrollView and cannot be seen.
What am I missing so that I can drag the image out of the ScrollView and into the main UIView screen? So that it is always shown when dragged around the screen.
Thanks
You need to turn of the ScrollViews' clipsToBounds property inside the attributes inspector.
Related
I want to achieve label/Button embededd in UIImageView in iOS Swift like shown in image.Has anyone done that?
You just need to play with UIView, UILabel And UIImageView.
You view hierarchy will be like below...
- UIView (mainView)
- UIImageView (imageView)
- UILabel
You need to make mainView.clipsToBounds = true so that after giving corner radius to it, it's subview will not go beyond its superview's bounds.
For imageView, you can set its content mode to aspect fill/ aspect fit as per your requirement.
Have a square UIView with clipsToBounds property set to YES which contains UIImageView and UILabel. The image view should cover all the view frame. The label should be positioned at the bottom of the view over the image view. Then just set appropriate corner radius (half of the view's height) for the view's layer and set its masksToBounds property to YES. That's it
In my app, I need to add subview in another view but my issue is that height and width of parentView is 50*50 and height of subview is 150*150 so how can I add this? because when I add this view, rest portion of subview is getting cropped.
The edges are bounded in the smaller UIView. Because the UIView is smaller it is going to crop out the larger subview. if you still want the super view to be 50x50 and don't want the larger subview cropped out then turn off setClipsToBound property of the UIView:
Swift: view.setClipsToBound = false
Objective-C: [view setClipsToBound:NO];
Another solution is just to make the subview smaller or make the superview containing the large subview larger.
I have an UIView with a UIButton and a UITableView. I constrained the UIButton (left, top, right, bottom) to (0,0,0,-) with a height of 50px. Below i constrained the UITableView (left, top, right, bottom) to (0,0,0,0) so that the screen would be filled with both views as such:
In this case the UIButton is above the UITableView in the scene outliner:
However whenever I reorder the view in the UIView so that the TableView is above the UIButton in the Scene Outliner it also moves my UITableViewCells but not my UITableView:
The constraints are the same and nothing is moved except for the layering in the scene outliner. Why do my UITableViewCells move down whenever i place my UITableView above my UIButton?
Interface Builder does that when "Adjust Scroll View Insets" in view controller attributes is checked.
I have a subclass of UIScrollView class and this scroll have vertical content. But I need drag and drop this UIScrollView in the parent view on horizontal direction. How can I implement this?
You must have a specific hierarchy:
Before you do anything you must go to your StoryBored and deselect the Autolayout option under the FileInspector.
View
ScrollView
ContainerView (if you want one or have one)
View
UIControl (if you have one)
THE CONTENTS OF YOUR VIEW.
You must however make a declaration of the scrollView in your header file:
IBOutlet UIScrollView *yourScrollViewName;
In your main under viewDidLoad:
-(void)viewDidLoad {
yourScrollViewName.translatesAutoresizingMaskIntoConstraints = NO;
[yourScrollViewName setScrollEnabled:YES];
[yourScrollViewName setContentSize:CGSizeMake(320 ,554)]; //320 is the x which is the width. change this to make it horizontal.
//554 is the Height this has to be larger that the screen size in order to have vertical scrolling.
[yourScrollViewName setPagingEnabled:NO];
}
I have a UIView which I need to stretch to the width of a UIScrollView. The problem is the next:
I'd need to stretch that UIView (which is EGOTableViewPullRefresh, just a custom UIView). In the view initialization I put [_refreshHeaderView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];. I tried:
-(void)scrollViewDidZoom:(UIScrollView *)scrollView {
NSLog(#"scrollViewDidZoom");
[_refreshHeaderView setFrame:CGRectMake(0.0f, 0.0f - webScroller.bounds.size.height, webScroller.frame.size.width, webScroller.bounds.size.height)];
}
But it just looks as the image. If I enter to a iOS designed page (such as Mobile Google), it looks ok:
How can I do that?
The size.width of a UIScrollView is width of the view on your device, not the width of the contents inside the scroll view (which would be scrollView.contentSize.width).
This means, if "your view" is outside the UIScrollView you do want the scroll view width, but if your view is inside the scroll view you need the content width.
Notice the bottom/Google screenshot you provided. Notice how there is no horizontal scrolling? In this case the scroll view contents size width is the same as the scroll view width so it works perfectly. The upper/stack overflow image does have a horizontal scroll bar though. So the content width of the scroll view is bigger than the scroll view width.
Short answer: Try setting your view to be the scrollView.contentSize.width, not scrollView.frame.size.width