2011-03-30 10 views
0

내 FirstViewController에서 내 SecondViewController 메서드를 실행하려고합니다.이 메서드는 cuz라고 불립니다. 로그 콘솔에서 내 메시지 (NSLog (@ "printSomething"))를 봅니다. . 문제는 해당 메서드에서 UIToolBar를 이동하려고하지만 그렇지 않다는 것입니다. 나는 다른의 ViewController에서 호출 할 때 UIToolBar 이동,하지만 ... 메소드가 실행 작동 자신의 ViewController에서 메소드를 호출하지만, UIToolBar는 아무 것도 설정하지 않으면다른 클래스의 toolBar 애니메이트

FirstViewController.m

UIBarButtonItem *flipButton = [[UIBarButtonItem alloc] 
           initWithTitle:@"Opciones"            
             style:UIBarButtonItemStyleBordered 
             target:secondViewController 
             action:@selector(showOptions)]; 

SecondViewController.m

-(void)showOptions{ 
NSLog(@"printSomething"); 
[self.toolBar setFrame:CGRectMake(0, 40, 320, 50)]; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:.35]; 
[self.toolBar setFrame:CGRectMake(0, 180, 320, 50)]; 
[self.toolBar setUserInteractionEnabled:YES]; 
[UIView commitAnimations]; 

} UR 리플레이에 대한

감사합니다.

답변

0
이에 NSLog 문을 변경

:

NSLog(@"self.toolbar is 0x%x",self.toolBar); 

을하고 값이 null이 아닌 경우를 참조하십시오. 이것은 매우 일반적인 문제입니다 - null 객체에 메시지를 보내는 것은 Objective-C의 런타임 오류가 아닙니다.

+0

0x0을 출력합니다. 어쨌든 어떻게 작동해야합니까? –

+0

이것은 변수가 null이라는 것을 의미합니다. 아무 것도 가리 키지 않습니다. 도구 모음에 대한 유효한 참조를 두 번째보기 컨트롤러에 제공해야합니다. 두 번째 뷰 contoller를 인스턴스화 할 때이를 매개 변수로 전달한 다음 self.toolbar = MyToolbarParameter를 수행 할 수 있습니다. – Rayfleck

관련 문제