문제

내가 사용하고 신속하고 있는 클래스라는 ViewController()연결되어 있는 내 c++코드가 필요합니다.내가받고자 하는 경고를 표시하는 뷰를 다른 클래스입니다.나는 다음 코드를 사용하여 그러나 그것은 열리지 않습니다 경고를 상자입니다.어떤 아이디어가?

public class SomeClass {

        func showAlert(title:String, body:String) {
            var alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
            alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))

}
도움이 되었습니까?

해결책

    func showAlert(title:String, body:String) {
        var alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))        
        var vc: ViewController = ViewController()
        vc.presentViewController(alert, animated: true, completion: nil)
    }
.

다른 팁

전화 presentViewControllerUIViewController 에 전달 h UIAlertViewController.

에 UIViewController:

자체입니다.presentViewController(경고,애니메이션:true,완성:nil)

alertUIAlertViewController.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top