단위 테스트에서 UITextField에서 becomeFirstResponder 메서드를 호출하려고하는데, 즉 첫 번째 응답자가되지 않는 것을 얻고 있습니다.UITextField 첫 번째 응답자 만들기
UITextField *textField = [self.controller.searchBar valueForKey: @"_searchField"];
// textField = [[UITextField alloc] initWithFrame:CGRectMake(10.0, 10.0, 400.0, 44.0)];
[self.navigationController.navigationBar addSubview:textField];
textField.enabled = YES;
STAssertTrue([textField becomeFirstResponder],
@"TextField should be a first responder.");
내가 여기서 뭔가를 놓치고 아래로
코드가 보인다?
당신이 호출하고있는 객체의 생명주기의 순간에 따라,'self.navigationCopntroller.navigationBar'는 == nil 일 수 있습니다. 이 경우 NO는 올바른 동작입니다. –