다른 viewcontroller에서 호출 할 때 작업 시트를 만드는 함수를 만들려고합니다. 문제는 지침 시트가 만들어지기는했지만 지정된 클릭 작업을 수행 할 수없는 것입니다. 사실 대표는 절대 호출되지 않습니다. 버튼 중 하나를 클릭하면 작업 시트가 닫힙니다. 함수에 대한UIActionsheet 대리자 clickedButtonAtIndex가 호출되지 않습니다.
내 코드는 다음과 같습니다
func shareAction(){
var sheet: UIActionSheet = UIActionSheet();
print("Calling share action!");
let title: String = "Tell friends, make plans";
sheet.title = title;
sheet.addButtonWithTitle("Cancel")
sheet.addButtonWithTitle("WhatsApp");
sheet.addButtonWithTitle("Facebook");
sheet.addButtonWithTitle("Message");
sheet.addButtonWithTitle("More");
sheet.cancelButtonIndex = 0;
sheet.delegate=self;
sheet.showInView(self.view)
}
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int)
{
print("clicking the action sheet")
if(buttonIndex ==0){
print("this is 0")
}
이 NSObject의 및 UIActionSheetDelegate를 확장하는 클래스 안에 있습니다. 나는 모든 문제를 겪었으며 문제의 원인에 관해서 혼란 스럽다.
'UIAlertController'를 사용하지 않는 이유가 무엇입니까? 대리인 대신 추가 한 각 작업에 대한 완료 블록을 사용합니다. 'UIActionSheet'와'UIAlertView' 둘 다'UIAlertController'를 위해 더 이상 사용되지 않습니다. – keithbhunter
나는 내 코드를 iOS 7과 호환되도록 유지하고 8 이상 버전의 다른 코드를 작성하는 것을 피하려고합니다. 그것은 강력한 이유는 아니지만 alertview 이전 버전 지원이 없기 때문에, 나는 uiactionsheet를 사용하는 것이 좋습니다. –
iOS 7을 지원해야하는 구체적인 이유는 무엇입니까? 대다수의 사용자가 이미 9에 있습니다. Xcode 8/iOS 10은 iOS 7에 대한 지원을 중단합니다. [이 링크 참조] (https://twitter.com/jamesthomson/status/747451011183280128) – keithbhunter