我正在尝试根据单独的类文件中发生的情况在一个视图中触发动画。它得到了方法,它确实吐出了两个NSLog
语句,但没有提交UIView Animation
这是代码:
视图控制器.h
@interface ViewController : UIViewController {
}
-(void)closeMenu;
视图控制器.m
-(void)closeMenu{
//close the menu
NSLog(@"Got here");
[UIView animateWithDuration:0.6 animations:^{
[UIView setAnimationBeginsFromCurrentState:YES]; // so it doesn't cut randomly, begins from where it is
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[menuView setFrame:CGRectMake(menuView.frame.origin.x, -menuView.frame.size.height, menuView.frame.size.width, menuView.frame.size.height)];
}];
NSLog(@"Got here2");
}
OtherClass.m (注释代码可能与本题无关,实际应用中当然还在使用,只是觉得可能更容易理解)
#import "ViewController.h"
...
//- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
//{
ViewController *foo = [[[ViewController alloc] init] autorelease];
//SelectableCellState state = subItem.selectableCellState;
//NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
//switch (state) {
//case Checked:
//NSLog(@"Changed Sub Item at indexPath:%@ to state \"Checked\"", indexPath);
//close the menuView
[foo closeMenu];
//break;
//case Unchecked:
//NSLog(@"Changed Sub Item at indexPath:%@ to state \"Unchecked\"", indexPath);
//break;
//default:
//break;
//}
}