2016-10-27 2 views
0

でそのプロパティを使用することはできませんsb.instantiateViewController(withIdentifier:)からvc10を作成し、ViewController10にその型を変換してもそのpropertyを使用することはできません。Q:(sb.instantiateViewControllerからwithIdentifierをVCを作成:)迅速

下記これは私のコードです:

vc9:

let sb = UIStoryboard.init(name: "Main", bundle: nil) 
var vc10 = sb.instantiateViewController(withIdentifier: "ViewController10") 

//vc10.delegate = self // there is the error: Value of type 'UIViewController' hs no member 'delegate' 
(ViewController10(vc10)).delegate = self // this did not work too 

self.navigationController!.pushViewController(vc10, animated: true) 

vc10:

var delegate:ViewController9? // this is the property delegate 

答えて

1

あなたはのようにそれを初期化するときは、ViewController10に変換する必要があります

var vc10 = sb.instantiateViewController(withIdentifier: "ViewController10") as! ViewController10