iOS Check ViewController有ChildViewController吗?

时间:2016-06-24 10:20:54

标签: ios objective-c childviewcontroller

我想在viewController有任何ChildViewController时做点什么。

我使用下面的代码添加子viewController:

MultPeople=[]
while condition:
    Person=People()
    # Here you somehow get the new cX and cY values
    Person.x=cX
    Person.y=cY
    MultPeople.append(Person)
for index,man in enumerate(MultPeople):
    print (index,man.x,man.y)
    xplot=man.x
    yplot=man.y
    cv2.circle(frame1, (xplot, yplot), 2, [50, 20, 255], 3)

现在如何检查ParentVC是否有ChildVC?

1 个答案:

答案 0 :(得分:3)

你可以这样做

for (UIViewController *child in parentVC.childViewControllers) {
    if ([child isKindOfClass:[childVC class]) {
        //your ChildVC here
    }
}

希望这个帮助