Note that there are some explanatory texts on larger screens.

plurals
  1. POTime taken to load a uiscrollview
    primarykey
    data
    text
    <p>I am trying to find the time taken for a uiscrollview to be displayed on a screen. I have a uibutton which when clicked creates a label with a very long text and adds it to a scrollview. Then the scrollview is added as a subview to self.view. I need to know the time taken for the scrollview to be displayed on the screen. Please help. Thanks in advance. Code below</p> <pre><code>- (IBAction)clickeMe:(id)sender { self.start=[NSDate date]; NSString *text="a very long text"; NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text]; NSRange range1 = NSMakeRange(100, 300); [attributedText setAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:range1]; UILabel *label1=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 700, 1000)]; [label1 setAttributedText:attributedText]; [label1 setNumberOfLines:0]; [label1 sizeToFit]; scrollviewtest *scrollview=[[scrollviewtest alloc]init]; scrollview.frame=CGRectMake(10, 50, 700, 1000); CGSize maxSize = CGSizeMake(label1.frame.size.width, CGFLOAT_MAX); CGSize labelSize = [label1 sizeThatFits:maxSize]; [scrollview addSubview:label1]; scrollview.contentSize = CGSizeMake(700, labelSize.height); [self.view addSubview:scrollview]; [self performSelector:@selector(viewLoaded) withObject:nil]; } -(void)viewLoaded { NSLog(@"[viewloaded]"); NSTimeInterval timeInterval = [self.start timeIntervalSinceNow]; NSLog(@"time taken is %f",fabs(timeInterval)); } </code></pre> <p>The problem with the above code is that viewLoaded is actually getting called before the scrollview appears on the screen.</p>
    singulars
    1. This table or related slice is empty.
    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