동일한 슬라이드 애니메이션이 서브 메뉴 인 this과 같은 메뉴가 있습니다. SecondMenu.xib라는 xib 파일 이름을 만듭니다. 파일 소유자는 UIViewController이며 SecondMenuController로 이름을 지정합니다. REFrosted (check the link) 프로젝트를 확인하면 DEMOMenuViewController (UIViewController)가 있습니다. 메서드 didSelectRowAtIndexPath :. 내 코드에서 변경했습니다.NSArrayM replaceObjectAtIndex : withObject : 객체는 'Nothing이 될 수 없습니다.'
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < 1; i++) {
[controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
SecondMenuController *controller = [self.viewControllers objectAtIndex:0];
if ((NSNull *)controller == [NSNull null]) {
controller = [[SecondMenuController alloc] initWithNibName:@"SecondMenu" bundle:nil];
[self.viewControllers replaceObjectAtIndex:0 withObject:controller];
}
controller.view.frame = CGRectMake(-self.view.frame.size.width, 0,self.view.frame.size.width,self.view.frame.size.height);
[self.view addSubview:controller.view];
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
controller.view.frame = CGRectMake(0, 0,self.view.frame.size.width,self.view.frame.size.height);
} completion:^(BOOL finished) {
NSLog(@"Done!");
}];
//[self hideMenu];
}
하위 메뉴 (즉, SecondMenuController)에 연결할 때 해당 코드가 작동합니다. 내 SecondMenuController에서 버튼을 추가합니다 (이 버튼은 DEMOHomeViewController에 연결되며 스토리 보드 식별자는 homeController입니다). (나는 첫 번째 코드에서 위에서 언급 무엇을로) : 여기에 내가 didSelectRowAtIndexPath에 내 코드로 변경하기 전에 내가 REFrosted이 코드를 얻을 내 버튼
- (IBAction)buttonConnect:(id)sender {
DEMONavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"];
DEMOHomeViewController *homeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"homeController"];
navigationController.viewControllers = @[homeViewController];
self.frostedViewController.contentViewController = navigationController;
[self.frostedViewController hideMenuViewController];
}
의 코드입니다. 왜이 오류가 발생합니까?
'NSInvalidArgumentException', reason: '*** -[__NSArrayM replaceObjectAtIndex:withObject:]: object cannot be nil'
모든 파일을 가져옵니다. 내가 이해 한대로, 파일 소유자에게 연결하는 파일을 가져올 때. 이것은 모든 메서드 나 함수를 제어 할 수 있다는 것을 의미합니다.이 메서드는 내 SecondMenuController에 인스턴스화 할 때 사용됩니다 (이 메서드는 경험이 풍부하고 틀린 경우 수정합니다. 시스템 작동 방법을 알고 싶습니다.). 내 코드를 참조하십시오. 내가 여기서 뭔가 못 찾았 니? 당신을 위해이 문제를 해결할 수있는 방법에 대한 조언을 듣고이 오류가 발생하는 이유를 설명합니다.
DEMONavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"];
DEMOHomeViewController *homeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"homeController"];
navigationController.viewControllers = @[homeViewController];
오류 메시지에 대해 이해하지 못하는 점은 무엇입니까? 그것은'controller'가 nil이라고 말합니다, 그것이 nil이 아니라고 확인 했습니까? NSLog() 예를 들어? 코드를 디버깅해야합니다. – zaph
예 homeViewController는 nil입니다. 왜 그게 없습니까? 클래스는 이미 보드에 연결되어 있습니다. – user3818576
디버깅 할 시간입니다. 신중하게 모든 것을 확인하고 오타, 클래스 이름 등을 다시 확인하십시오. 문서를 다시 읽으십시오. – zaph