Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

objective c - Loading xib crashes app

Hello all I am having a issue with showing a xib file from the main file not sure why this is happening with some of the xib files and not others.

if(segment == @"1"){
    Results1 *myView1 = [[Results1 alloc]initWithNibName:@"Results1" bundle:nil];
    [self.view addSubview:myView1.view];
}else if(segment == @"2"){
    Results2 *myView2 = [[Results2 alloc]initWithNibName:@"Results2" bundle:nil];
    [self.view addSubview:myView2.view];
}else if(segment ==@"3"){
    Results3 *myView3 = [[Results3 alloc]initWithNibName:@"Results3" bundle:nil];
    [self.view addSubview:myView3.view];
}else if(segment ==@"4"){
    Results4 *myView4 = [[Results4 alloc]initWithNibName:@"Results4" bundle:nil];
    [self.view addSubview:myView4.view];
}

Is my code the first xib files opens but not the rest I am not sure why, I have added .h files:

#import "Results1.h"
#import "Results2.h"
#import "Results3.h"
#import "Results4.h"

the app ends up on this line when debugging:

@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([TestTypingToolAppDelegate class]));
}

and then it crashes, anyone have any idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Tim, here is a picture from the Interface Builder, maybe it helps you:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...