В ShareKit код должен определить, где находится rootViewController, чтобы он мог отображать модальное представление.По какой-то причине в iOS 5 происходит сбой кода:
// Try to find the root view controller programmically
// Find the top window (that is not an alert view or other window)
UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];
if (topWindow.windowLevel != UIWindowLevelNormal)
{
NSArray *windows = [[UIApplication sharedApplication] windows];
for(topWindow in windows)
{
if (topWindow.windowLevel == UIWindowLevelNormal)
break;
}
}
UIView *rootView = [[topWindow subviews] objectAtIndex:0];
id nextResponder = [rootView nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]])
self.rootViewController = nextResponder;
else
NSAssert(NO, @"ShareKit: Could not find a root view controller. You can assign one manually by calling [[SHK currentHelper] setRootViewController:YOURROOTVIEWCONTROLLER].");
Это ударяет по утверждению.
Что не так с простым использованием следующего кода вместо этого?
rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
Кажется, это работает нормально.Это потерпит неудачу при некоторых условиях?