Ios UIViewController未在情节提要中打开?
在我的登录页面中,当我检查服务器输出是否为“false”时,如果不是false,我将添加此代码以移动到主viewcontroller类 但是下面的代码对我不起作用Ios UIViewController未在情节提要中打开?,ios,objective-c,uiviewcontroller,storyboard,segue,Ios,Objective C,Uiviewcontroller,Storyboard,Segue,在我的登录页面中,当我检查服务器输出是否为“false”时,如果不是false,我将添加此代码以移动到主viewcontroller类 但是下面的代码对我不起作用 ViewController *main = [self.storyboard instantiateViewControllerWithIdentifier:@"App"]; [self.navigationController pushViewController:main animated:YES]; 请帮助我,我的序列名是“
ViewController *main = [self.storyboard instantiateViewControllerWithIdentifier:@"App"];
[self.navigationController pushViewController:main animated:YES];
请帮助我,我的序列名是“App”,主viewController id也是“App”
用于发送url请求和获取服务器响应的代码
stringValue包含我的url
NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString: stringValue]];
request.HTTPMethod = @"POST";
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
request.HTTPBody = myRequestData;
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSString * serverOutput= [[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@",serverOutput);
if(serverOutput!=NULL)
{
if([serverOutput isEqualToString:@"login"])
{
[self performSegueWithIdentifier:@"App" sender:self];
}
else
{
NSError *jsonError = nil;
id mylibrary = [NSJSONSerialization JSONObjectWithData:[serverOutput dataUsingEncoding:NSUTF8StringEncoding]options:0 error:&jsonError];
NSDictionary *ratedBookList = [(NSDictionary*)mylibrary objectForKey:@"library"];
[self saveMylibrary:ratedBookList];
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
ViewController *main = [self.storyboard instantiateViewControllerWithIdentifier:@"App"];
[self.navigationController pushViewController:main animated:YES];
[alertView dismissWithClickedButtonIndex:0 animated:YES];
}
} ];
_alertView = [[UIAlertView alloc] initWithTitle:@"Please Wait..."
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(120, 75.5);
[alertView addSubview:activityIndicator];
[activityIndicator startAnimating];
[alertView show];
}
确保
情节提要ID
正确且唯一
确保self.storyboard具有有效内存,并且具有VC
乙二醇
您确定
@“App”
与身份检查器中的情节提要ID
中的字符串相同吗?你能从NSLog中发布一些错误代码吗?是的,这是相同的,当我单击“登录”时,我没有收到任何错误。活动指示器将运行并停止。在同一页中。但我可以在日志中看到我的服务器输出和响应,所有这些都显示已登录,但我的viewcontroller没有显示你发布的代码上的放置断点。检查正在发生的事情。发布一些屏幕截图,可以给我们一些提示发生了什么。上面提到的移动到nxt viewcontroller的代码正在执行,但view controller没有showing@mango:对我来说,没有检查它也起作用。编辑了答案。试试看你的意思是什么确保self.storyboard有有效的内存,并且它有脚本的vc实例应正确初始化,并且viewcontroller的nib应位于该故事板中
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
ViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"App"];
[self.navigationController pushViewController:lvc animated:YES];