2009-05-18 6 views
4

에 응답하지 내가 이렇게 설정된 UIActionSheet이 있습니다UIActionSheet는 터치

-(void)trash:(id)sender 
{ 
UIActionSheet *sheet = [[[UIActionSheet alloc] initWithTitle:@"Delete" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove text" otherButtonTitles:@"Remove tags", nil] autorelease]; 

[sheet showInView:self.view]; 

}

시트가 의도 한대로 화면의 하단, 모든 올바른에서 나타납니다. 그러나 버튼 중 아무 것도 활성화되어 있지 않습니다. 유일한 방법은 홈 버튼을 터치하는 것입니다.

누락 된 것이 있습니까?

뷰 self.view는 뷰 컨트롤러의 뷰입니다. 이상한 점은 키보드 위에 있기 때문에 전체 화면 높이보다 작다는 것입니다.

// Never called 
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; 
{ 
    NSLog(@"%d",buttonIndex); 
} 

// Never called 
- (void)actionSheet:(UIActionSheet *)actionSheet  didDismissWithButtonIndex:(NSInteger)buttonInde 
{ 

} 

// Never called 
- (void)actionSheet:(UIActionSheet *)actionSheet  willDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 

} 

// Called if I hit Home button 
- (void)actionSheetCancel:(UIActionSheet *)actionSheet 
{ 

} 


// Called second 
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet 
{ 

} 

// Called first 
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet 
{ 

} 
+2

:

I는 AppDelegate에이 방법을 [시트 showInView : self.view.window]; 완벽하게 작동합니다. –

+0

나는 이것도 경험했다. 창에 표시하는 것이 잘 작동하므로 그 방법을 사용하고 있습니다. – rpetrich

답변

0

firstResponder 상태를 다시 확인하십시오.

1

보기에 키보드가있는 경우 키보드가 표시되는 textfield/textview가 첫 번째 응답자입니다. 터치에 반응하는 컨트롤은 첫 번째 응답자 여야합니다.

작업 시트를 표시 할 때 첫 번째 응답자인지 확인하십시오.

0

보기를 self.vew에 표시하지 말고 Appdelegate의 루트보기에 표시해야합니다.

[appDelegate.window.subviews objectAtIndex : 0]을 사용하십시오.

-(UIView *) getRootView { 
return [self.window.subviews objectAtIndex:0]; 

} 흥미롭게 I 이렇게하면