AppDelegate question ( warning: 'AppDelegate' may not respond to ... )
Ok, here is the deal, I keep on getting this warning :
开发者_开发知识库'AppDelegate' may not respond to '-setViewMovedUp:'
This is my implementation file :
- (IBAction)viewUp {
AppDelegate *moveUp = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[moveUp setViewMovedUp:YES]; //move Shot View
[self setViewMovedUp:YES];
}
and this is my AppDelegate Implementation file :
- (void)setViewMovedUp:(BOOL)movedUp {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
CGRect rect = shotView.frame;
if (movedUp)
{
rect.size.height -= 200;
}
shotView.frame = rect ;
CGRect rect2 = pageControl.frame;
if (movedUp)
{
rect2.size.height -= 395;
}
pageControl.frame = rect2 ;
[UIView commitAnimations];
}
I'm gessing that I get a warning because the AppDelegate is not a view, but inside the method I`m calling a view, is there a way I can code differently and better to get this annoying warning go away ? ( the method still works by the way ... )
Thanks !
You need to declare the method in your interface (.h) file. Put this in your AppDelegate.h:
- (void)setViewMovedUp:(BOOL)movedUp;
That should do it.
Warning should go away if you declare method in app delegate header file:
//AppDelegate.h
...
- (void)setViewMovedUp:(BOOL)movedUp;
精彩评论