Finding the rootViewController in iOS
问题 In ShareKit, the code needs to determine where the rootViewController is so it can show a modal view. For some reason, the code is failing in 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