我是新的ios,我使用storyboard实现列表数据功能演示,包括添加数据。 在我的AddWrokLogViewController中,我有一个方法(IBAction)完成:(id)sender bind + button。 如下所示,在我的do函数中,我想检查用户输入并通过http post保存用户输入数据。当远程保存成功发布数据时,我想回到列表视图。
像以前一样我搜索苹果文章介绍故事板,但在这个演示中,当用户点击添加按钮时,直接转移到列表页面视图:http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual /SecondiOSAppTutorial/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011318-CH1-SW1如果我使用AFHTTPClient在远程服务器成功中保存数据,则返回列表页面视图,或者仍然添加页面视图并显示错误消息。
任何人都可以给我一些建议,谢谢!
NSString *url = [NSString stringWithFormat:@"%@",api_createworklog];
NSDictionary *params=[NSDictionary dictionaryWithObjectsAndKeys:uname,@"loginname",token,@"token",beginTime
,@"beginTime",content,@"content",address,@"address",projectNameTemp,@"projectName"
,workType,@"workType",workDate,@"workDate",validDate,@"validDate", nil];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:BASE_URL]];
[client postPath:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *responseString = [operation responseString];
NSDictionary *data = [responseString objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
NSString *sysCode = [data objectForKey:@"syscode"];
NSString *businessCode = [data objectForKey:@"businesscode"];
if(sysCode != nil && ![sysCode isEqualToString:@""] && businessCode != nil && ![businessCode isEqualToString:@""]){
if([sysCode isEqualToString:ws_access_success] && [businessCode isEqualToString:ws_access_success]){
//[self.navigationController popViewControllerAnimated:YES];
addSuccess = true;
} else{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"添加失败" message:responseString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSString *responseString = operation.responseString;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"访问服务器异常,添加失败!" message:responseString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}];