2009-06-08 2 views
0

다음과 같은 문제가 있습니다 : UIViewController가있는 UIView이지만 사용자 정의 키보드와 같은 다른 뷰가 있으며이 "키보드"에는 다른 UIViewController가 있습니다. 내가 좋아하는 원래의 UIView에이 키보드를 추가 해요 그다른 UIView 내부의 UIView는 메서드를 호출하지 않습니다

CustomizedKeyboard *customized = [[CustomizedKeyboard alloc] initWithNibName:@"CustomizedKeyboard" bundle:[NSBundle mainBundle]]; 
    [self.view addSubview: customized.view]; 
    customized.view.frame = CGRectMake(0, 480, 320, 260);  
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.5]; 
    customized.view.frame = CGRectMake(0, 200, 320, 260); 
    [UIView commitAnimations]; 
    [customized release]; 

나는이 메서드를 호출 할 때, 뷰 내보기에 아무런 문제가 나타납니다,하지만 문제는이 사용자 정의 키보드가와 관련된 몇 가지 방법을 가지고있다 내가 어떤 버튼을 터치하면 버튼,하지만 난

가지고 - [NSCFType의 buttonPressed] : 인식 할 수없는 선택 예를 0x1065f80 '

누구나 아이디어가 전송 무엇을 그것은 수 있습니다? 더 나은 이해를 위해이 문제가있는이 샘플 프로젝트를 만듭니다. http://www.2shared.com/file/6174665/9c9bbd44/ArchiveFixed.html (다운로드 링크) 정말 도움이 되었어요. thx

답변

1

보기 컨트롤러를 해제합니다. 뭔가 그것에 매달릴 필요가 있습니다.

0

두 가지가 있습니다. 첫째, 실제로 사용자 정의 번들을 사용하고 있습니까? 난 일반적으로 여기에 통과, 특히 간단한 애플 리케이션 (당신이 설명하는대로) 본적이있다. 둘째, 모든 뷰의 설정이 완료 될 때까지 하위 뷰를 추가하지 마십시오.

이 시도 : 당신이 성공적으로 부모의 스택에 추가 취득으로

CustomizedKeyboard *customized = [[CustomizedKeyboard alloc] initWithNibName:@"CustomizedKeyboard" bundle: nil]; 
customized.view.frame = CGRectMake(0, 480, 320, 260);  
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5]; 
customized.view.frame = CGRectMake(0, 200, 320, 260); 
[UIView commitAnimations]; 
[self.view addSubview: customized.view]; 
[customized release]; 

당신은 오랫동안 사용자 정의 인스턴스를 해제하는 것이 안전합니다.

0

당신은 항상 alloc, retain, copy를 사용하면 Apple이 따라야한다는 것을 기억해야합니다. 당신은이 객체의 평생 책임입니다. 코드가 옳은 것처럼 보일 지 모르지만 약간 다를 것입니다. 객체를 생성하고 relasing하지만 코드에이 객체가 필요합니다.

keyborad보기 컨트롤러 인스턴스 인 의 제안 사항에 따라 클래스 범위 속성을 만들어야하고 키보드보기 컨트롤러 인스턴스를이 속성에 추가하면 릴리스하기 전에 필요한 것입니다.

이와 같이 예제 코드가 변경되었습니다. 예

@synthisize의 customizedKeyboard위한

;

CustomizedKeyboard *customized = [[CustomizedKeyboard alloc] initWithNibName:@"CustomizedKeyboard" bundle:[NSBundle mainBundle]]; 
self.customizedKeyboard = nil; 
[self.customizedKeyboard release]; //prevent retain counts memory leaks 
self.customizedKeyboard = customized; 
[customized release]; 

[self.view addSubview: self.customizedKeyboard.view]; 
customized.view.frame = CGRectMake(0, 480, 320, 260);  
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5]; 
customized.view.frame = CGRectMake(0, 200, 320, 260); 
[UIView commitAnimations]; 

그것은이 변경 작품이어야한다.

관련 문제