Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not calculate the height of a scrollview when their is no internet connection
    primarykey
    data
    text
    <p>I have a scrollview with a dynamic height. The height depends on the image and the text that I got back from my core database. I have the following.</p> <p>In my <code>ViewDidLoad</code> I call my method <code>getNewsItem</code>.</p> <p>Here is how the method looks like.</p> <pre><code>-(void)getNewsItem{ NSManagedObjectContext *context = [RKManagedObjectStore defaultStore].persistentStoreManagedObjectContext; NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"News"]; NSLog(@"news ID IN METHOD %d",_newsId); NSPredicate *predicate = [NSPredicate predicateWithFormat: @"new_id = %d",_newsId]; [fetchRequest setPredicate:predicate]; NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"new_id" ascending:YES]; fetchRequest.sortDescriptors = @[descriptor]; NSArray *matches = [context executeFetchRequest:fetchRequest error:nil]; newsItem = [matches objectAtIndex:0]; lblTitle.text = newsItem.pnt_new_title; lblTitle.font = [UIFont fontWithName:@"ShadowsIntoLightTwo-Regular" size:16.0]; lblTitle.textColor = [UIColor whiteColor]; NSString *datetext = [newsItem.new_date substringWithRange:NSMakeRange(0, 11)]; lblDate.text = datetext; lblDate.font = [UIFont fontWithName:@"TitilliumWeb-Regular" size:15.0]; NSString *imgUrl = @""; imgUrl = [NSString stringWithFormat:@"http://mosaqua.appmax.be/%@",newsItem.new_imgurlbig]; NSData *imgData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imgUrl]]; UIImage *image = [UIImage imageWithData:imgData]; self.img_Picture.image = [UIImage imageWithData:imgData]; float ratioImage = image.size.width/image.size.height; float ratioPlaceholder = 320/206; float width; float heigth; float x; if(ratioImage &lt; ratioPlaceholder){ width = 206 * ratioImage; heigth = 206; }else{ width = 320; heigth = 320/ratioImage; } if (heigth &lt; self.view.bounds.size.width){ x = (self.view.bounds.size.width - width) / 2; }else{ x = 0; } NSLog(@"x is %f",x); if(heigth &lt; 206){ self.img_titlback.frame= CGRectMake(-4, heigth-8, self.view.bounds.size.width+5, 45); self.lblTitle.frame = CGRectMake(40, heigth-8, self.view.bounds.size.width, 40); self.btnBack.frame = CGRectMake(5, heigth, 67, 28); self.lblDate.frame = CGRectMake(7, heigth+30, self.view.bounds.size.width, 45); [self updateScrollView:newsItem.pnt_new_description andHeight:heigth+60]; }else{ [self updateScrollView:newsItem.pnt_new_description andHeight:300]; } self.img_Picture.frame = CGRectMake(x, 0, width, heigth); } </code></pre> <p>Webview method</p> <pre><code>-(void)updateScrollView:(NSString *)text andHeight:(float)height{ NSLog(@"till here in scrollview"); UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(10, height,self.view.bounds.size.width-30, 20)]; [[webView scrollView] setBounces: NO]; webView.delegate = self; [scrollView addSubview:webView]; [self setWebDescription:webView]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload