我正试图从故事板中呈现一个视图,这是我viewDidLoad
的样子:
- (void)viewDidLoad
{
[super viewDidLoad];
// I'm doing some stuff here...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
UIViewController *rvc = [storyboard
instantiateViewControllerWithIdentifier:@"RVC"];
[rvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:rvc animated:YES];
//[self performSegueWithIdentifier:@"pushRVC" sender:self];
}
代码似乎运行良好,因为没有崩溃,但视图不会出现。它也不适用于performSegueWithIdentifier
。
奇怪的是,在我使用NSURLConnection
连接到PHP页面之前,它工作正常。
以下代码没问题,我没有遇到任何问题:
- (void)viewDidLoad
{
[super viewDidLoad];
// I'm doing the same stuff here...
NSMutableData *responseData = [[NSMutableData alloc] init];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL
URLWithString:@"myURL"]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self];
[connection start];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *responseString = [[NSString alloc] initWithData:responseData
encoding:NSUTF8StringEncoding];
NSError *jsonError;
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
NSDictionary *jsonResults = [jsonParser objectWithString:responseString
error:&jsonError];
if (jsonResults == nil) {
NSLog(@"%@", [jsonError localizedDescription]);
}
else {
// Messing around with the results...
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
UIViewController *rvc = [storyboard instantiateViewControllerWithIdentifier:@"RVC"];
[rvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:rvc animated:YES];
//[self performSegueWithIdentifier:@"pushRVC" sender:self];
}
这对我来说很奇怪,不知道它可能是什么?
提前致谢。