2017-11-22 8 views
0

// UITableViewCellで //画面上でタブをクリックすると「画像を開く」と表示されます 2017-11-22 13:15:31.023129 + 0530 chat [1376:265960]警告:そのビューはウィンドウの階層にはありません! "UIViewCellから新しいビューコントローラを開く

func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) 
    { 
     let tappedImage = tapGestureRecognizer.view as! UIImageView 
     print("open image") 
     let sb = UIStoryboard.init(name: "Main", bundle: nil) 
     let vc : openimageinfullscreen = sb.instantiateViewController(withIdentifier: "openimageinfullscreen") as! openimageinfullscreen 
     self.window?.rootViewController?.present(vc, animated: true, completion: nil) 
    } 
+0

である必要があります。ちょうどself.present(vc、アニメーション:true、完了:なし) – Daniel

+0

をUITableViewCellで試してみてください。私がself.presentを使うことを許さない。それは "タイプの値 'imagefrommyside'のメンバー 'present'がありません" – Sandeep

答えて

0

トップの表示コントローラを取得して表示する必要があります。 これを試してください。別のノートで


func topViewController() -> UIViewController? { 
    if var topController = UIApplication.shared.keyWindow?.rootViewController { 
     while let presentedViewController = topController.presentedViewController { 
      topController = presentedViewController 
     } 
     return topController 
    } 
    return nil 
} 


func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) 
{ 
    let tappedImage = tapGestureRecognizer.view as! UIImageView 
    print("open image") 
    let sb = UIStoryboard.init(name: "Main", bundle: nil) 
    let vc : openimageinfullscreen = sb.instantiateViewController(withIdentifier: "openimageinfullscreen") as! openimageinfullscreen 
    self.topViewController()?.present(vc, animated: true, completion: nil) 
} 

、あなたはクラス名を使用するべきではありませんが、小さな文字で始まります。 openimageinfullscreenクラスは OpenImageInFullscreen

+0

ありがとう..... .....働いた – Sandeep

関連する問題