2011-12-04 3 views
1

다음 명령문을 사용하여 UIPickerView와 함께 UIActions 시트를 닫습니다. UIPickerView는 닫기 버튼이 정의되어 있습니다.UIActionSheet가 자동으로 왜곡되는 이유는 무엇입니까?

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];  

닫기 버튼을 클릭하기 전에 UIActions 시트가 자동으로 해제됩니다. UIActionsheet가 버튼 프레스를 통해 호출되고이 버튼을 누르면 활성화 된 직후에 UIActionsheet가 닫히기 때문에이 이유에 대한 한 가지 이론이 있습니다. 닫기 버튼이 위의 명령문에서 참조 된 버튼 인 버튼인지 어떻게 확인합니까? 프로그래밍 방식으로 만든 닫기 버튼의 인덱스를 찾으려면 어떻게합니까?

답변

0

closebuttonUIActionSheet에 없으므로 "cancelButton"이라고 가정합니다. 다음과 같이하면됩니다.

[actionSheet dismissWithClickedButtonIndex:[actionSheet cancelButtonIndex] animated:YES]; 
+0

실제로 닫기 버튼이 추가되었습니다. (이하). 지정된 코드가 '취소'버튼과 함께 작동하지만 UIPicker.UISegmentedControl * closeButton = [[UISegmentedControl alloc] initWithItems : [NSArray arrayWithObject : @ "Done"]]]과 함께 사용하고 싶지 않습니다. closeButton.momentary = YES; closeButton.frame = CGRectMake (260, 7.0f, 50.0f, 30.0f); closeButton.segmentedControlStyle = UISegmentedControlStyleBar; closeButton.tintColor = [UIColor blackColor]; [closeButton addTarget : 자기 액션 : @selector (dismissActionSheet :) forControlEvents : UIControlEventValueChanged]; – Shaddy

관련 문제