我正从AppDelegate班上查看我ParentEndViewController目前是否是可见课程.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
ParentEndViewController *parent = [storyboard instantiateViewControllerWithIdentifier:@"ParentEndViewController"];
if (parent.isViewLoaded && parent.view.window){
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:displayName
message:body
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
NSLog(@"current view is parent!");
}
else{
NSLog(@"current view is not parent!");
}
Run Code Online (Sandbox Code Playgroud)
它正在打印current view is not parent!".但我确信我的应用程序上运行的当前视图是ParentEndViewController,它应该打印current view is parent!.
问题出在哪儿?
我在课堂上有7种方法.当我收到一条特定的消息时,我必须从这7种方法中随机调用一种方法.我的示例代码是:
-(void)poemAbcd{
UIImage *image = [UIImage imageNamed: @"abcd_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:80 with:220];
}
-(void)poemHumptyDumpty{
UIImage *image = [UIImage imageNamed: @"humpty_dumpty.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:80 with:170];
}
-(void)poemBlackship{
UIImage *image = [UIImage imageNamed: @"black_sheep.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:66 with:229];
}
-(void)poemRowRow{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemHappy{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemItsyBitsy{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemTwinkleTwinkle{ …Run Code Online (Sandbox Code Playgroud)