PDA

View Full Version : crash - exit on removeFromSuperview




IDMah
Mar 5, 2012, 02:21 PM
Hi all.

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

with:


UIView *removeView;
while((removeView = [self viewWithTag:999]) != nil) {
[removeView removeFromSuperview];
}


which I set up with:


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



robbieduncan
Mar 5, 2012, 04:15 PM
Give us some context. Which method is this code in?

IDMah
Mar 5, 2012, 08:41 PM
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

-(void)drawCard
{
// stuff //
}

// which is called by

- (void)drawRect:(CGRect)rect {
if cardtype = 1
{
[self drawCard];
}
}

robbieduncan
Mar 6, 2012, 04:33 AM
I imagine removing views during drawRect: or any code that is called by it is a very bad idea.

IDMah
Mar 7, 2012, 01:34 AM
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