Thursday 15 May 2014

objective c - iOS: ScrollView doesn't scroll after subviews are added -


I am loading an image from the web and moves some HTML under it to the UIScrollView. It sits inside a navigation controller inside a tabbar controller. The scrollview will not scroll when I load the subviews. What am I missing?

Here is the viewpoint:

  - (zero) viewDidoad {NSDLL * imageURL = [NSDL URL YouthRestring: [[Self display] image]]; NSDTA * ImageData = [NSDTATA DATAVITY content of the: imageURL]; UIImage * image = [UIImage imageWithData: imageData]; If ([[USScreen main screen] bound]. Size width = 600) {CGSize newSize = CGSizeMake (300.0, 140.6); UIGraphicsBeginImageContext (newSize); [Image DrawInrct: CGRactMake (0.0, 0.0, New Size. Width, New Size.)]; Image = UIGraphicsGetImageFromCurrentImageContext (); } CGRact view = Limits of 0.04, 0.0, [[USScreen main screen]] Size, width, ([USScreen main screen] border] Size: Height - [[Navigation Controller] Navigation Bar] Bounds Seas. - [[[Self tabbyrc controller] TabBR] Direct limits] .ize.height)); NSLog (@ "% @", NSStringFromCGRect (viewFrame)); UIScrollView * sv = [[UIScrollView alloc] initWithFrame: Viewfinder]; [SV SetsScrolled Enabled: Yes]; [Self set view: SV]; CGRTF frame = CGRactMake (0.0, 0.0, imageize.width, imaginesheight); UIImageView * iv = [[UIImageView alloc] initWithFrame: frame]; [Iv set image: image]; [Iv set content mode: UIViewContentModeScaleAspectFit]; [Iv set transclusionsautorerisingmask intactstationes: no]; [Iv setbackgram color: [UIColor redColor]]; [SV addSubview: iv]; [Self-Setting View: iv]; NSDictionary * nameMap = @ {@ "imageView": [auto image view]}; NSArray * Horizontal Concept = [NSLayoutConstraint constraintsWithVisualFormat: @ "H: | -10- [imageView] -10- |" Options: NSLayoutFormatAlignAllCenterX Metrics: Zero View: nameMap]; [SV add constants: horizontal consultants]; NSArray * verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: | -0- [imageView]" option: NSLayoutFormatAlignAllTop metric: zero view: nameMap]; [SV ad constants: vertical consultans]; UIWebView * wv = [[UIWebView alloc] initWithFrame: CGRectMake (0.0, 150.0, 300.0, 600.0)]; [Wv load html string: [[self display] text] baseURL: zero]; [SV addSubview: wv]; [Self set acidity text: VV]; }   

UPDATE

I have added the following lines, and there is no change yet. I can not scroll at all.

  [sv set content size: CGSizeMake (320.0, 750.0)]; [[VV Scroll Power] setcroll is enabled: no]; [[VV ScrollView] Setbones: No]; [Wv setUserInteractionEnabled: NO];    

You get a contentSize for your scroll view - someone Without the size of the content, the scroll view will not know how far you want to scroll. By default, UIScrollView has zero value content size, so it needs to be set.

No comments:

Post a Comment