您可以从this link下载此项目 执行此程序点击按钮"点击此处立即出售您的黄金"进入
用户名:hermon_yonaito@bullionscope.com
密码:Wau2017?
问题-1
它将启动您到仪表板。选择"交易记录"那不显示记录。检查为什么记录没有显示?并在视图控制器中显示记录?
问题-2
第二个问题是选择Profile执行ProfileViewController.m.On更新用户配置文件updateButtonTap函数已执行。它没有更新。它仍然是缓冲。如何执行配置文件更新?< / p>
这是ProfileViewController.m
#import "ProfileViewController.h"
@interface ProfileViewController ()
@end
@implementation ProfileViewController
- (void)viewDidLoad
{
[super viewDidLoad];
currentUser = [SingletonClass sharedSingletonClass].settingsDictionary[@"User"];
selectedValues=[NSMutableDictionary dictionary];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSMutableDictionary *paramDict=[NSMutableDictionary dictionary];
[paramDict setObject:@"ios" forKey:@"request"];
[paramDict setObject:[NSString stringWithFormat:@"%@",currentUser.user_id] forKey:@"user_id"];
[GeneralWebservices webserviceMainSplashCall:paramDict webserviceName:Webservice_Profile OnCompletion:^(id returnDict, NSError *error) {
if ([returnDict[@"success"] intValue] ==1)
{
[self setProfileData:returnDict[@"data"]];
provinceList=[NSMutableArray arrayWithArray:returnDict[@"provincedata"]];
questions1Array=[NSMutableArray arrayWithArray:returnDict[@"questiondata"]];
}
else
{
[self get_register_data];
}
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
-(void)setProfileData:(NSMutableDictionary*)dataDict
{
profilePicImageView.imageURL=[NSURL URLWithString:dataDict[@"image_file_thumb"]];
[firstNameLabel setText:dataDict[@"first_name"]];
[lastNameLabel setText:dataDict[@"last_name"]];
[dateOfBirthLabel setText:dataDict[@"user_dob"]];
[postalAddressTextfield setText:dataDict[@"user_address"]];
[mobileTextfield setText:dataDict[@"user_mobile"]];
[question1Textfield setText:dataDict[@"user_answer_1"]];
[question2Textfield setText:dataDict[@"user_answer_2"]];
[LLGButton setTitle:dataDict[@"user_llg"] forState:UIControlStateNormal];
[provinceButton setTitle:dataDict[@"user_province"] forState:UIControlStateNormal];
[districtButton setTitle:dataDict[@"user_district"] forState:UIControlStateNormal];
[villageTextfield setText:dataDict[@"user_village"]];
[question1Button setTitle:dataDict[@"user_question_1"] forState:UIControlStateNormal];
[question2Button setTitle:dataDict[@"user_question_2"] forState:UIControlStateNormal];
[self callforDistrict:@"get_district.php" idForItem:dataDict[@"district_id"]];
[self callforLLG:@"get_llg.php" idForItem:dataDict[@"llg_id"]];
[selectedValues setObject:dataDict[@"user_question_1_id"] forKey:@"user_question_1"];
[selectedValues setObject:dataDict[@"user_question_2_id"] forKey:@"user_question_2"];
[selectedValues setObject:dataDict[@"province_id"] forKey:@"user_province"];
[selectedValues setObject:dataDict[@"district_id"] forKey:@"user_district"];
[selectedValues setObject:dataDict[@"llg_id"] forKey:@"user_llg"];
}
-(void)callforDistrict:(NSString*)serviceName idForItem:(NSString*)idForItem
{
dispatch_async(dispatch_get_main_queue(), ^{
[self getdistdata:idForItem];
});
}
-(void)callforLLG:(NSString*)serviceName idForItem:(NSString*)idForItem
{
dispatch_async(dispatch_get_main_queue(), ^{
[self getIIL:idForItem];
});
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidLayoutSubviews
{
[profileScrollView setContentSize:CGSizeMake(self.view.frame.size.width, 700)];
}
- (IBAction)uploadPictureButtonTap:(UIButton *)sender
{
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select option" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
@"Open Gallery",
@"Take Photo",
nil];
popup.tag = 1;
[popup showInView:[UIApplication sharedApplication].keyWindow];
}
- (IBAction)provinceButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
NSMutableArray *provinceNames=[NSMutableArray array];
for (NSMutableDictionary*pro in provinceList)
{
[provinceNames addObject:pro[@"province_name"]];
}
LGActionSheet *sheet=[[LGActionSheet alloc] initWithTitle:@"Select Province" buttonTitles:provinceNames cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil];
sheet.tagOfSheet=2;
sheet.heightMax=300;
sheet.delegate=self;
[sheet showAnimated:YES completionHandler:nil];
}
- (IBAction)districtButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
NSMutableArray *names=[NSMutableArray array];
for (NSMutableDictionary*pro in districList)
{
[names addObject:pro[@"district_name"]];
}
LGActionSheet *sheet=[[LGActionSheet alloc] initWithTitle:@"Select District" buttonTitles:names cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil];
sheet.heightMax=200;
sheet.tagOfSheet=3;
sheet.delegate=self;
[sheet showAnimated:YES completionHandler:nil];
}
- (IBAction)LLGButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
NSMutableArray *names=[NSMutableArray array];
for (NSMutableDictionary*pro in llgList)
{
[names addObject:pro[@"llg_name"]];
}
LGActionSheet *sheet=[[LGActionSheet alloc] initWithTitle:@"Select LLG" buttonTitles:names cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil];
sheet.heightMax=200;
sheet.tagOfSheet=4;
sheet.delegate=self;
[sheet showAnimated:YES completionHandler:nil];
}
- (IBAction)villageButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
}
- (IBAction)question1ButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
NSMutableArray *ques1=[NSMutableArray array];
for (NSMutableDictionary*pro in questions1Array)
{
[ques1 addObject:pro[@"question_name"]];
}
LGActionSheet *sheet=[[LGActionSheet alloc] initWithTitle:@"Select Question 1" buttonTitles:ques1 cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil];
sheet.tagOfSheet=5;
sheet.heightMax=300;
sheet.delegate=self;
[sheet showAnimated:YES completionHandler:nil];
}
- (IBAction)question2ButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
NSMutableArray *ques2=[NSMutableArray array];
for (NSMutableDictionary*pro in questions1Array)
{
[ques2 addObject:pro[@"question_name"]];
}
LGActionSheet *sheet=[[LGActionSheet alloc] initWithTitle:@"Select Question 2" buttonTitles:ques2 cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil];
sheet.tagOfSheet=6;
sheet.heightMax=300;
sheet.delegate=self;
[sheet showAnimated:YES completionHandler:nil];
}
- (IBAction)updateButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[selectedValues setObject:@"ios" forKey:@"request"];
[selectedValues setObject:[NSString stringWithFormat:@"%@",currentUser.user_id] forKey:@"user_id"];
[selectedValues setObject:postalAddressTextfield.text forKey:@"address"];
[selectedValues setObject:mobileTextfield.text forKey:@"user_mobile"];
[selectedValues setObject:question1Textfield.text forKey:@"user_answer_1"];
[selectedValues setObject:villageTextfield.text forKey:@"user_village"];
[GeneralWebservices webserviceCallWithData:selectedValues webserviceName:Webservice_ProfileUpdate dataToPost:imageData imageName:imageName OnCompletion:^(id returnDict, NSError *error) {
if ([returnDict[@"success"] intValue] ==1)
{
}
else
{
UIAlertView* alert = [[UIAlertView alloc] init];
[alert setTitle:@"Updated Successfully"];
//[alert setMessage:returnDict[@"message"]];
[alert addButtonWithTitle:@"OK"];
[alert show];
}
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
- (IBAction)saveButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
}
- (void)actionSheet:(LGActionSheet *)actionSheet buttonPressedWithTitle:(NSString *)title index:(NSUInteger)index
{
dispatch_async(dispatch_get_main_queue(), ^{
if (actionSheet.tagOfSheet==2)
{
[selectedValues setObject:provinceList[index][@"province_id"] forKey:@"user_province"];
[provinceButton setTitle:provinceList[index][@"province_name"] forState:UIControlStateNormal];
[districList removeAllObjects];
[llgList removeAllObjects];
[districtButton setTitle:@"District *" forState:UIControlStateNormal];
[LLGButton setTitle:@"LLG *" forState:UIControlStateNormal];
[selectedValues removeObjectForKey:@"district"];
[selectedValues removeObjectForKey:@"llg"];
[self callforDistrict:@"get_district.php" idForItem:provinceList[index][@"province_id"]];
}
else if(actionSheet.tagOfSheet==3)
{
[selectedValues setObject:districList[index][@"id"] forKey:@"user_district"];
[districtButton setTitle:districList[index][@"district_name"] forState:UIControlStateNormal];
[llgList removeAllObjects];
[LLGButton setTitle:@"LLG *" forState:UIControlStateNormal];
[selectedValues removeObjectForKey:@"llg"];
[self callforLLG:@"get_llg.php" idForItem:districList[index][@"id"]];
}
else if(actionSheet.tagOfSheet==4)
{
[selectedValues setObject:llgList[index][@"id"] forKey:@"user_llg"];
[LLGButton setTitle:llgList[index][@"llg_name"] forState:UIControlStateNormal];
}
else if(actionSheet.tagOfSheet==5)
{
[selectedValues setObject:questions1Array[index][@"question_id"] forKey:@"user_question_1"];
[question1Button setTitle:questions1Array[index][@"question_name"] forState:UIControlStateNormal];
}
else if(actionSheet.tagOfSheet==6)
{
[selectedValues setObject:questions1Array[index][@"question_id"] forKey:@"user_question_2"];
[question2Button setTitle:questions1Array[index][@"question_name"] forState:UIControlStateNormal];
}
});
}
-(IBAction) returnTextField:(id)sender
{
CGRect frame = self.view.frame;
frame.origin.y = 0;
[UIView animateWithDuration:0.3 animations:^{
self.view.frame = frame;
}];
[self.view endEditing:YES];
}
- (BOOL)textFieldShouldEndEditing:(UITextField*)textField
{
return YES;
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[self animateTextField:textField up:NO];
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self animateTextField:textField up:YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self animateTextField:textField up:NO];
}
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (popup.tag) {
case 1: {
switch (buttonIndex) {
case 0:
[self openPhotoLibraryButton:self];
break;
case 1:
[self openCameraButton:self];
break;
default:
break;
}
break;
}
default:
break;
}
}
- (IBAction)openCameraButton:(id)sender
{
[self.view endEditing:YES];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
picker.allowsEditing = false;
[self presentViewController:picker animated:true completion:nil];
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Alert!" message:@"Camera is not connected" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
}
- (IBAction)openPhotoLibraryButton:(id)sender
{
[self.view endEditing:YES];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
picker.allowsEditing = true;
[self presentViewController:picker animated:true completion:nil];
}
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:nil];
imageData=[[NSData alloc]init];
if ([info[@"UIImagePickerControllerMediaType"] isEqualToString:@"public.image"])
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
if (!image)
{
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
NSURL *imagePath = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
image=[SettingsClass rotateImageAppropriately:image];
NSString *imageNamewithformat = [imagePath lastPathComponent];
imageName=@"assets.jpg";
NSString *Imageformat = [imageNamewithformat substringFromIndex: [imageNamewithformat length] - 3];
if ([Imageformat isEqualToString:@"JPG"]||[Imageformat isEqualToString:@"jpg"]) {
imageData=UIImageJPEGRepresentation(image, 0.33f);
imageName=@"assets.jpg";
}
else if ([Imageformat isEqualToString:@"PNG"]||[Imageformat isEqualToString:@"png"])
{
imageData=UIImagePNGRepresentation(image);
imageName=@"assets.png";
}
else
{
imageData=UIImageJPEGRepresentation(image, 0.33f);
imageName=@"assets.jpg";
}
[profilePicImageView setImage:image];
}
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
CGPoint temp = [textField.superview convertPoint:textField.frame.origin toView:nil];
UIInterfaceOrientation orientation =
[[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait){
if(up) {
int moveUpValue = temp.y+textField.frame.size.height;
animatedDis = 264-(self.view.frame.size.height-moveUpValue-35);
}
}
else if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
if(up) {
int moveUpValue = self.view.frame.size.height-temp.y+textField.frame.size.height;
animatedDis = 264-(self.view.frame.size.height-moveUpValue-35);
}
}
else if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
if(up) {
int moveUpValue = temp.y+textField.frame.size.height;
animatedDis = 352-(self.view.frame.size.height-moveUpValue-100);
}
}
else
{
if(up) {
int moveUpValue = temp.y+textField.frame.size.height;
animatedDis = 352-(768-moveUpValue-100);
}
}
if(animatedDis>0)
{
const int movementDistance = animatedDis;
const float movementDuration = 0.3f;
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: nil context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
if (orientation == UIInterfaceOrientationPortrait){
self.view.frame = CGRectOffset( self.view.frame, 0, movement);
}
else if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
self.view.frame = CGRectOffset( self.view.frame, 0, movement);
}
else if(orientation == UIInterfaceOrientationLandscapeLeft) {
self.view.frame = CGRectOffset( self.view.frame, 0, movement);
}
else {
self.view.frame = CGRectOffset( self.view.frame, 0, movement);
}
[UIView commitAnimations];
}
}
- (IBAction)backtohomeview :(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)getdistdata:(NSString*)idForItem
{
self.view.userInteractionEnabled = NO;
NSString *strURL;
strURL = [NSString stringWithFormat:@"http://bullionscope.com/Gold_Phase3/webservices/get_district.php?request=ios&province_id=%@",idForItem];
NSDictionary *headers = @{ @"cache-control": @"no-cache",
@"postman-token": @"900e1577-4876-cd9a-d24c-cb0631b4a1fb" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strURL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
// [self AlertController:@"Alert!" :@"Request time out"];
}
else
{
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSString *success = [[jsonDic objectForKey:@"success"]stringValue];
if (
[success isEqualToString:
@"1"])
{
districList=[NSMutableArray arrayWithArray:[jsonDic objectForKey:@"data"]];
dispatch_async(dispatch_get_main_queue(), ^{
self.view.userInteractionEnabled = YES;
});
}
else
{
// [self AlertController:@"Alert!" :@"No record found"];
dispatch_async(dispatch_get_main_queue(), ^{
self.view.userInteractionEnabled = YES;
});
}
}
}];
[dataTask resume];
}
-(void)get_register_data
{
self.view.userInteractionEnabled = NO;
NSString *strURL;
http://bullionscope.com/Gold_Phase3/webservices/get_all_province.php?request=ios
strURL = [NSString stringWithFormat:@"http://bullionscope.com/Gold_Phase3/webservices/get_all_province.php?request=ios"];
NSDictionary *headers = @{ @"cache-control": @"no-cache",
@"postman-token": @"900e1577-4876-cd9a-d24c-cb0631b4a1fb" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strURL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
// [self AlertController:@"Alert!" :@"Request time out"];
}
else
{
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSString *success = [[jsonDic objectForKey:@"success"]stringValue];
if (
[success isEqualToString:
@"1"])
{
provinceList=[NSMutableArray arrayWithArray:[jsonDic objectForKey:@"data"]];
dispatch_async(dispatch_get_main_queue(), ^{
self.view.userInteractionEnabled = YES;
});
}
else
{
// [self AlertController:@"Alert!" :@"No record found"];
dispatch_async(dispatch_get_main_queue(), ^{
self.view.userInteractionEnabled = YES;
});
}
}
}];
[dataTask resume];
}
@end
答案 0 :(得分:0)
你的api正在返回零数据。
这是错误描述 -
Error Description: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html"
问题在于你的api处理。
使用此
的GeneralWebservices类中的替换方法 +(void) webserviceMainSplashCall:(NSMutableDictionary *)parameters webserviceName:(NSString*)webserviceName OnCompletion:(void(^)(id returnDict, NSError* error))callbackBlock{
/*
// parameter keys & values, values will be dynamic.
"forward_date" = "26-05-2016";
"gold_weight" = 345;
request = ios;
"user_id" = 1;
*/
NSString *url = [NSString stringWithFormat:@"%@%@",App_BaseUrl,webserviceName];
NSLog(@"url is this = %@", [NSString stringWithFormat:@"%@%@",App_BaseUrl,webserviceName]);
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
AFJSONResponseSerializer *jsonReponseSerializer = [AFJSONResponseSerializer serializer];
// This will make the AFJSONResponseSerializer accept any content type
jsonReponseSerializer.acceptableContentTypes = nil;
manager.responseSerializer = jsonReponseSerializer;
// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
// manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:[NSString stringWithFormat:@"%@%@",App_BaseUrl,webserviceName] parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
}
progress:^(NSProgress * _Nonnull uploadProgress)
{
}
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject)
{
callbackBlock( responseObject, nil );
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
{
// check error here.
NSLog(@"Error Description: %@",error);
callbackBlock( nil, nil );
}];
}
输出的最终屏幕截图 -