mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Fix visibility assert on iOS 7
It appears that didMoveToViewController: can be called with nil, yet self.parentViewController will *not* be nil. This can result in calling parent view controller's visibility depth. Instead of asserting, these methods should return NSNotFound which also happens to be a really large number, effectively infinite depth.
This commit is contained in:
@@ -40,7 +40,10 @@ ASVisibilityDepthImplementation;
|
|||||||
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController
|
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController
|
||||||
{
|
{
|
||||||
NSUInteger viewControllerIndex = [self.viewControllers indexOfObject:childViewController];
|
NSUInteger viewControllerIndex = [self.viewControllers indexOfObject:childViewController];
|
||||||
NSAssert(viewControllerIndex != NSNotFound, @"childViewController is not in the navigation stack.");
|
if (viewControllerIndex == NSNotFound) {
|
||||||
|
//If childViewController is not actually a child, return NSNotFound which is also a really large number.
|
||||||
|
return NSNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
if (viewControllerIndex == self.viewControllers.count - 1) {
|
if (viewControllerIndex == self.viewControllers.count - 1) {
|
||||||
//view controller is at the top, just return our own visibility depth.
|
//view controller is at the top, just return our own visibility depth.
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ ASVisibilityDepthImplementation;
|
|||||||
|
|
||||||
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController
|
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController
|
||||||
{
|
{
|
||||||
|
NSUInteger viewControllerIndex = [self.viewControllers indexOfObject:childViewController];
|
||||||
|
if (viewControllerIndex == NSNotFound) {
|
||||||
|
//If childViewController is not actually a child, return NSNotFound which is also a really large number.
|
||||||
|
return NSNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
if (self.selectedViewController == childViewController) {
|
if (self.selectedViewController == childViewController) {
|
||||||
return [self visibilityDepth];
|
return [self visibilityDepth];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user