我想在一個視圖中觸發動畫,基於單獨的類文件中發生的情況。它得到的方法,通過這樣的事實,它並吐出兩個NSLog
聲明支持,但並沒有提交UIView Animation
動畫沒有通過執行到另一個視圖控制器
下面是代碼:
ViewController.h
@interface ViewController : UIViewController {
}
-(void)closeMenu;
ViewController.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(註釋的代碼可以是irrelev螞蟻對這個問題,當然還是在實際應用中使用。 Jut認爲這可能會讓它更容易理解)
#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;
//}
}
你是什麼意思它不承諾?你的意思是動畫不會發生?在設置menuView框架的動畫的行上設置一個斷點。斷點到達了嗎? menuView不是零嗎? – rmaddy
@rmaddy是啊動畫沒有發生。斷點已經達到,menuView不爲零,我用IB製作了 –
你確定它是在Interface Builder中連接的嗎? – WrightsCS