내 프로그램이 성공적으로 컴파일되지만 버튼을 누르면 프로그램이 충돌합니다. 오류이 줄에 나타납니다Swift에서 UIActionSheet를 초기화하려고 할 때 EXC_BAD_ACCESS
import UIKit
class ViewController: UIViewController, UIActionSheetDelegate{
@IBOutlet var button:UIButton
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed(AnyObject) {
let choice = UIActionSheet(title: "Select source", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles:"camera", "libary")
choice.showInView(self.view)
}
}
: 여기 viewController.swift입니다
let choice = UIActionSheet(title: "Select source", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles:"camera", "library")
을 그리고 여기에 오류 텍스트입니다 :
EXC_BAD_ACCESS (코드 = 2, 주소 = 0x0으로)
var로 바꾸려고했지만 다른 시뮬레이터에서 실행했지만 결과는 같습니다.
고맙습니다. 작동합니다! Btw, 나는 "var"를 "let"으로 변경했고 너무 효과적입니다! – Roman
흠, actionSheet (myActionSheet : UIActionSheet !, clickedButtonAtIndex buttonIndex : Int)가 작동하지 않습니다. 코드는 동일하지만 클래스 구현에이 행을 추가합니다. – Roman
대리인을 올바르게 확인하십시오. 이 코드를 실행 한 다음 –