Quote:
Originally Posted by DGYWFT
My problem is when i set the delegate to self the app freezes. If I set it to anything else, it will only run the fadeup, but then never calls fade down. Know any way to fix this? The CALayer subview (theColorA) is in my custom view class 'mainview'
Any tips?
|
Can you be more specific as to what happens when the app freezes? Does it compile and then freeze when it gets to that block of code? If so, I had this problem already with an infinite loop from callbacks, but I don't remember how I solved it. I'd have to look at the code. If you can give me any more specific details, that might help. I'm no pro though, so I can't guarantee I can solve it, hehe.
As another note: I highlighted in bold the next part I want to mention. The delegate is like your doorway to other parts of your app. By setting the delegate to "self", you're telling it that the current view controller contains all delegate methods/functions, and that the application should look to "self" or whatever view controller you set to find whatever methods it needs to call. So, by setting the delegate to something else, you'd also have to put the fadeImageDown method wherever you set the delegate. Did you move it when you tried setting it to another view controller?
WARNING: I've been off iPhone for about a week and my memory can go fast at times, but I 'think' you have to set a view controller as your delegate. Anyone who can confirm this would be great. Maybe the area you are calling this code isn't from a view controller?
I'd just like to point out that you are setting an infinite loop of callbacks. So as long as whatever screen is on the stack that is using this code, it will constantly be executing it. If this is the desired effect, that's fine, but I would still wrap it in a conditional:
Code:
- (void) fadeImageUp
{
if (!done)
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:3.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(fadeImageDown)];
mainview.theColorA.opacity = 1.0;
[UIView commitAnimations];
}
}
Sorry for the mouthful. Let me know how it goes (good OR bad), and post either relevant info for others to share/learn from.