SCNView to UIView?

泪湿孤枕 提交于 2019-12-13 21:30:53

问题


Is it possible to translate from a SCNView to a UIView? I have a login button from an overlay on my SCNView but I want the login button to take the user to a UIView to login.


回答1:


May not be the most elegant way to do it but something like this might work for you.....

- (void) handleTap:(UITapGestureRecognizer*)gestureRecognizer {

    // get tap location
    CGPoint p = [gestureRecognizer locationInView:scnView];

    // convert to sk scene coordinates
    CGPoint p2D = [scnView.overlaySKScene convertPointFromView:p];
    //test if we hit the login button
    SKNode *loginButton = [scnView.overlaySKScene nodeAtPoint:p2D];

    // assuming your loginButton is of type SKLabelNode
    if (loginButton != nil && ( [loginButton isMemberOfClass:[SKLabelNode class]]  )) // add other tests here
    { 
        // Here you can add code to transition to another 
        // view controller to handle logins


    } else {
        // do hit test on scnView here for the 3D scene
        // .........
    }

}


来源:https://stackoverflow.com/questions/42032985/scnview-to-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!