0
我希望我的子視圖控制器標記爲「navView」,當應用程序啓動時顯示在屏幕外,當按下按鈕時動畫顯示。但是當我啓動模擬器時,「navView」已經出現。ViewDidLoad的問題
- (void)viewDidLoad
{
[super viewDidLoad];
draw1 = 0;
navView.frame = CGRectMake(-568, 0, 320, 568);
newsView.frame = CGRectMake(0, 0, 320, 568);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)sideNav:(id)sender {
if (draw1 == 0) {
draw1 = 1;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
navView.frame = CGRectMake(0, 0, 320, 568);
newsView.frame = CGRectMake(1136, 0, 320, 568);
[UIView commitAnimations];
} else {
draw1 = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
navView.frame = CGRectMake(0, 0, 320, 568);
newsView.frame = CGRectMake(-500, 0, 320, 568);
[UIView commitAnimations];
在'viewDidLoad',你確定'navView'不是'nil'? – rmaddy