PDA

View Full Version : strange




chhoda
Dec 29, 2008, 09:46 AM
@implementation SliderView

- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {

MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
MainViewController *mainVC = appDelegate.mainViewController;

CGRect rect = [self frame];
CGRect rectMV = [mainVC.channelPicker.moreView frame];
CGRect rectCP = [mainVC.channelPicker frame];
if(rect.origin.y < rectCP.origin.y) // it is in min position
{
CGPoint pt = CGPointMake(rectCP.origin.x + (rect.size.width / 2), rectMV.origin.y + (rect.size.height / 2));
UIImage *img = [UIImage imageNamed:@"slider_max.png"];
[self setImage:img]; //[UIImage imageNamed:@"slider_mini.png"];
[mainVC.channelPicker.moreView removeFromSuperview];
[mainVC.channelPicker removeFromSuperview];
[self setCenter:pt];
}
else // It is in max position
{
mainVC.channelPicker.moreView.hidden = FALSE;
mainVC.channelPicker.hidden = FALSE;
CGPoint pt = CGPointMake(rectCP.origin.x + (rect.size.width / 2), rectCP.origin.y - (rect.size.height/2)); //rectMV.origin.y;
[self setImage:[UIImage imageNamed:@"slider_mini.png"]];
[self setCenter:pt];
}
}


my class is inherited from UIImage class. Surprisingly in the else part self setImage works fine. in the if part self setImage crashes EXC_BAD_ACCESS

both the images are valid and are returing valid pointers.

Any ideas !!!

regards
ch



dejo
Dec 29, 2008, 11:34 AM
And you've added slider_max.png to your project?