在一個view類裏面獲取viewcontroller

- (UIViewController *)viewController {spa

    for (UIView* next = [selfsuperview]; next; next = next.superview) {class

        UIResponder *nextResponder = [next nextResponder];next

        if ([nextResponder isKindOfClass:[UIViewControllerclass]])view

        {vi

            return (UIViewController *)nextResponder;return

        }

    }

    returnnil;

}

相關文章
相關標籤/搜索