我在申请一开始就有以下内容:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Reminder:" message:@"foo" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
NSLog(@"%@ is the parent view",[alertView superview]); // prints "(null)"
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
...
}
并且UIAlertView仍然显示出来。怎么运作?
答案 0 :(得分:1)
警报视图显示在他们自己的窗口中。但是直到运行循环有机会运行才会发生这种情况。当您记录警报视图的超级视图时,警报尚未显示,这就是您获得(null)
的原因。