是否可以从 推送到新的视图控制器ConnectionDidFinishLoading
?
我有以下内容,它执行ConnectionDidFinishLoading
但不推送到新的视图控制器。
-(void)connectionWithURLString:(NSMutableArray *)urlString
{
NSDate *now = [NSDate date];
int userID = [[clientDataStruct.clientData objectForKey:@"number"] intValue];
NSDate *date = self.datePicker.date;
// NSLog(@"obj: %@", urlString);
NSString *extrString = [NSString stringWithFormat:@", customerdetails:{customer_id = %d, job_date = %@, date_created = %@}",userID,date, now];
NSString *post = [NSString stringWithFormat:@"json=quote:{%@%@}", urlString, extrString ];
NSLog(@"post: %@", post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *value = [defaults objectForKey:@"value"];
NSString *jsonUrl = [NSString stringWithFormat:@"xxx?task=add_quote&user_id=%@&customer_id=%@",value, [clientDataStruct.clientData valueForKey:@"number"]];
[request setURL:[NSURL URLWithString:jsonUrl]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
if (!connection)
NSLog(@"Connection failed!");
}
- (void)Success
{
UIStoryboard *subVc = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
UserTableView *userTable = [subVc instantiateViewControllerWithIdentifier:@"UserTableView"];
userTable.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController pushViewController:userTable animated:YES];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"%@", error);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[self performSelectorOnMainThread:@selector(Success) withObject:Nil waitUntilDone:YES];
NSLog(@"connectionDidFinishLoading%@", connection);
}
一切正常,并返回我的数据和数据被添加到SQL
. 我的NSLog
表明ConnectionDidFinishLoading
。但它不会推送到新的 View Controller。
感谢您的帮助,正在为此挠头。
感谢 Fahim 的建议允许我进一步调试,导航视图与返回的模型控制器中断。将其更改为推送,一切正常