오픈 소스 프로젝트에서 동시에 작업하는 동안 github 저장소를 https://github.com/istx25/schedules에서 사용할 수 있습니다. UIActionSheet에서 버튼을 누를 때마다 함수를 실행할 식별자를 케이스에 추가하려고합니다.스위프트 스위치 및 케이스 기능 처리
@IBAction func rightButton(sender : AnyObject) {
var sheet: UIActionSheet = UIActionSheet()
let title: String = "Please choose a block rotation"
sheet.title = title
sheet.delegate = self
sheet.addButtonWithTitle("Cancel")
sheet.addButtonWithTitle("Day Four")
sheet.addButtonWithTitle("Day Three")
sheet.addButtonWithTitle("Day Two")
sheet.addButtonWithTitle("Day One")
sheet.cancelButtonIndex = 0
sheet.showInView(self.view)
}
을 내가 같이하는 어떤 버튼을 연기하기 위해 스위치를 시작했습니다 :
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
switch buttonIndex {
case 0:
print("Go Back")
case 1:
print("Day Four")
// Day Four Function
case 2:
print("Day Three")
// Day Three Function
case 3:
print("Day Two")
// Day Two Function
case 4:
print("Day One")
// Day One Function
default:
print("Something's broken")
}
}
나는 그것의 푸시하는 각각의 경우를 꿔 다음과 같이 액션 시트의 코드는 자신의 func
방법을 사용하고 정확히 어떻게 접근 할 지 확신하지 못합니다. 아무도 도움이된다면 도움을주십시오. 이 질문을 이해하기 어려운 경우 알려주십시오. 그래서 Stackoverflow에 대한 도움을 청할 때 더 좋아질 수 있습니다! 미리 감사드립니다.
대신에'print ...'호출 대신에 함수를 사용하고 싶습니까? –