crash - exit on removeFromSuperview

Discussion in 'iOS Programming' started by IDMah, Mar 5, 2012.

  1. IDMah, Mar 5, 2012
    Last edited: Mar 5, 2012

    macrumors regular

    Joined:
    May 13, 2011
    #1
    Hi all.

    Trying to keep My View from being blurry.
    So I'm trying to remove the old views.

    with:

    Code:
    UIView *removeView;
    while((removeView = [self viewWithTag:999]) != nil) {
    	[removeView removeFromSuperview];
    }
    
    which I set up with:
    Code:
    
    UIImage *uiimage = [[UIImage alloc]retain]; 
    uiimage = [currentCard stampImage]; 
    CGSize mysize = uiimage.size; 
    UIGraphicsBeginImageContext(mysize);
    	
    [uiimage drawInRect:CGRectMake(stampPost.x,stampPost.y, stampSize.width, stampSize.height)
    blendMode:kCGBlendModeNormal alpha:alpahed]; 
    
    UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    		
    UIImageView *stampOverlay = [[UIImageView alloc] initWithImage:blendedImage]; 
    	
    [blendedImage release];
    
    [stampOverlay setFrame:CGRectMake(0,0,bounds.size.width,bounds.size.height)];
    [stampOverlay setAlpha:STAMPBASE];
    [stampOverlay setTag:999];
    	
    [self addSubview:stampOverlay];
    [stampOverlay release];
    
    
    I even tried to set the set the Views Alpha to 0.0f and that crashed too..
    basically I want the redraws to be cleared. before I draw update (redraw) the view.

    thanks
    Ian
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Give us some context. Which method is this code in?
     
  3. IDMah, Mar 5, 2012
    Last edited: Mar 5, 2012

    thread starter macrumors regular

    Joined:
    May 13, 2011
    #3
    Code in an NSView.

    It draws a card on the screen an populates it. the card is part of an XIB.

    thanks
    Ian

    oh and the above code is in
    Code:
     
    -(void)drawCard
    {
    // stuff // 
    }
    
    // which is called by
    
     - (void)drawRect:(CGRect)rect {
     if cardtype = 1
    {
      [self drawCard];
    }
    }
    
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    I imagine removing views during drawRect: or any code that is called by it is a very bad idea.
     
  5. thread starter macrumors regular

    Joined:
    May 13, 2011
    #5
    it's actually in a routine that get's called by drawRect. But Point taken.

    Not sure for now.. will more than likely have to rethink how I do things
    to make it work. I just I'll just hide the views for now.. ugly bad, but ..
    It seems to work..

    will Post a solution if I find one..

    thanks
    Ian
     

Share This Page