Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've basically reached the same conclusions as @Louis, but also made some comments within the code as to what I removed and why.</p> <pre><code>- (void)loadView { [super loadView]; CGRect theRect = CGRectMake(0, 0, 320, 480); UIView *view = [[UIView alloc] initWithFrame:theRect]; [view setBackgroundColor:[UIColor purpleColor] ]; self.view = view; [view release]; UIView *pippo = [[UIView alloc] initWithFrame:theRect]; [pippo setBackgroundColor:[UIColor redColor]]; [self.view addSubview:pippo]; [pippo release]; [self performSelector:@selector(scrollAdd:) withObject:nil afterDelay:2.0f]; } -(void)scrollAdd:(id)o { CGRect theRect = CGRectMake(0, 0, 320, 480); int numero = 1; scroll = [[UIScrollView alloc] initWithFrame:theRect]; [scroll setContentSize:CGSizeMake( 320*numero,1)]; [scroll setScrollEnabled:YES]; // img is already autoreleased, you're releasing again down below // --- UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"koala1b" ofType:@"jpg"]]; UIImageView *v2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"koala1b.jpg"]]; v2.frame = theRect; //--- [v2 setImage:img]; [scroll addSubview:v2]; [v2 release]; [self.view addSubview:scroll]; // NO !; img is autoreleased from imageWithContentsOfFile //--- [img release]; [self performSelector:@selector(scrollRemove:) withObject:nil afterDelay:2.0f]; } -(void)scrollRemove:(id)o { //--- UIImageView *theV = [[scroll subviews] objectAtIndex:0]; [scroll removeFromSuperview]; // you don't own theV because you didn't create it here, or send it a retain. So NO release // it also appears that you think you're responsible for releasing or cleaning up // a view's subviews. NO. Just call [scroll removeFromSuperview] and let scroll view // clean it's own resources. //--- [theV release]; [scroll release]; scroll = nil; [self performSelector:@selector(scrollAdd:) withObject:nil afterDelay:2.0f]; } </code></pre>
    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.
    1. VO
      singulars
      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