我有一個窗體,其中有一些文本字段和選擇後,當用戶點擊一個新的tableviewcontroller打開搜索按鈕下拉。在這個表視圖控制器中,它加載了一個從服務中獲取數據的函數。數據加載了一段時間,現在我想使用這個時間段之間的數據加載表格視圖我已經使用指標之間的活動指標,但它不起作用。我的代碼,活動指標不工作按鈕點擊IOS
-(void)loadCustomerRecords
{
_City = nil;
_Title=nil;
_Price=nil;
_LandArea=nil;
_Phone=nil;
_Image1=nil;
_location=nil;
_name=nil;
_email=nil;
_descrip=nil;
_type=nil;
_rooms=nil;
_washroom=nil;
_floor=nil;
_Id=nil;
_status=nil;
NSUserDefaults *string = [NSUserDefaults standardUserDefaults];
NSString *string1 = [string stringForKey:@"country"];
NSString *string2 = [string stringForKey:@"city"];
NSString *string3 = [string stringForKey:@"proptype"];
NSString *string4 = [string stringForKey:@"propstatus"];
NSString *string5 = [string stringForKey:@"proparea"];
NSString *string6 = [string stringForKey:@"area"];
NSString *string7 = [string stringForKey:@"min"];
NSString *string8 = [string stringForKey:@"max"];
if ([string4 isEqualToString:@"Property Status"]) {
string4 = @"";
}
if ([string3 isEqualToString:@"Property Type"]) {
string3 = @"";
}
if([string5 isEqualToString:@"Property Area"]){
string5 = @"";
}
else{
//concatenating strings
NSString *strappend=[NSString stringWithFormat:@"%@ %@",string6,string5];
string5 = strappend;
}
if ([string7 isEqualToString:@""] && [string8 isEqualToString:@""]) {
string7 = @"";
string8 = @"";
}
NSLog(@"AREA : %@", string5);
NSLog(@"country %@",string1);
NSLog(@"city %@",string2);
NSLog(@"property_type %@",string3);
NSLog(@"propertystatus %@",string4);
NSLog(@"propertyarea %@",string5);
NSLog(@"area %@",string6);
NSLog(@"min %@",string7);
NSLog(@"max %@",string8);
CustomTableViewCell *check=[[CustomTableViewCell alloc]init];
check.indicator.hidden=NO;
[check.indicator startAnimating];
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration
defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration:
defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
NSString *[email protected]"My URL";
NSURL * url = [NSURL URLWithString:urlLinkA];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
NSString *parameters = [NSString
stringWithFormat:@"country=%@&city=%@&propertytype=%@&propertstatus=%@&propertyare
a=%@",string1,string2,string3,string4,string5];
NSLog(@"parameter %@",parameters);
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[parameters dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask * dataTask =[defaultSession
dataTaskWithRequest:urlRequest
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
[check.indicator stopAnimating];
NSLog(@"Response:%@ %@\n", response, error);
if(error == nil)
{
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
NSLog(@"MY Response %@ ", dictionary);
NSArray *results = [dictionary objectForKey:@"property_data"];
NSLog(@"RESULT %@ ", results);
_City = [NSMutableArray array];
_Phone = [NSMutableArray array];
_LandArea = [NSMutableArray array];
_location = [NSMutableArray array];
_name = [NSMutableArray array];
_email = [NSMutableArray array];
_descrip = [NSMutableArray array];
_type = [NSMutableArray array];
_rooms = [NSMutableArray array];
_washroom = [NSMutableArray array];
_floor = [NSMutableArray array];
_Id = [NSMutableArray array];
_Price = [NSMutableArray array];
_Title = [NSMutableArray array];
for (NSDictionary * oneCustomer in results)
{
// Create a new Customer record
StringData * newCustomer = [[StringData alloc] init];
newCustomer.title1 = [oneCustomer objectForKey:@"property_title"];
NSLog(@"ID: %@ ", newCustomer.title1);
newCustomer.Area = [oneCustomer objectForKey:@"land_area"];
NSLog(@"Country: %@ ", newCustomer.Area);
newCustomer.images = [oneCustomer objectForKey:@"images"];
NSLog(@"IMAGE: %@ ", newCustomer.images);
newCustomer.City = [oneCustomer objectForKey:@"city"];
NSLog(@"CITY: %@ ", newCustomer.City);
newCustomer.phoneno = [oneCustomer objectForKey:@"dealer_phone"];
NSLog(@"ID: %@ ", newCustomer.phoneno);
newCustomer.location = [oneCustomer objectForKey:@"location"];
NSLog(@"ID: %@ ", newCustomer.location);
newCustomer.property_description = [oneCustomer objectForKey:@"property_description"];
NSLog(@"ID: %@ ", newCustomer.property_description);
newCustomer.property_type = [oneCustomer objectForKey:@"property_type"];
NSLog(@"ID: %@ ", newCustomer.property_type);
newCustomer.property_id = [oneCustomer objectForKey:@"property_id"];
NSLog(@"ID: %@ ", newCustomer.property_id);
newCustomer.status_property = [oneCustomer objectForKey:@"status_property"];
NSLog(@"ID: %@ ", newCustomer.status_property);
newCustomer.status = [oneCustomer objectForKey:@"status"];
NSLog(@"ID: %@ ", newCustomer.status);
newCustomer.dealer_email = [oneCustomer objectForKey:@"dealer_email"];
NSLog(@"ID: %@ ", newCustomer.phoneno);
newCustomer.dealer_name = [oneCustomer objectForKey:@"dealer_name"];
NSLog(@"ID: %@ ", newCustomer.dealer_name);
newCustomer.bath = [oneCustomer objectForKey:@"bathrooms"];
NSLog(@"ID: %@ ", newCustomer.bath);
newCustomer.rooms = [oneCustomer objectForKey:@"rooms"];
NSLog(@"ID: %@ ", newCustomer.rooms);
newCustomer.floors = [oneCustomer objectForKey:@"floors"];
NSLog(@"ID: %@ ", newCustomer.floors);
newCustomer.country = [oneCustomer objectForKey:@"country"];
NSLog(@"ID: %@ ", newCustomer.country);
newCustomer.Price = [oneCustomer objectForKey:@"price"];
NSLog(@"ID: %@ ", newCustomer.Price);
// Add our new Customer record to our NSMutableArray
[_Title addObject:newCustomer];
NSString *imageURL = @"http://www.pk.house/frontend/propertyimages/";
NSString *string3 = [imageURL stringByAppendingString:newCustomer.images];
newCustomer.images = string3;
NSLog(@"Image URL %@",string3);
// addObject:[oneCustomer objectForKey:@"property_title"]];
// NSLog(@"TET %@",_Title);
[_Price addObject:[oneCustomer objectForKey:@"price"]];
NSLog(@"TET %@",_Price);
[_Image1 addObject:[oneCustomer objectForKey:@"images"]];
NSLog(@"TET %@",_Image1);
[_City addObject:[oneCustomer objectForKey:@"city"]];
NSLog(@"TET %@",_City);
[_Phone addObject:[oneCustomer objectForKey:@"dealer_phone"]];
NSLog(@"TET %@",_Phone);
[_name addObject:[oneCustomer objectForKey:@"dealer_name"]];
NSLog(@"TET %@",_name);
[_email addObject:[oneCustomer objectForKey:@"dealer_email"]];
NSLog(@"TET %@",_email);
[_rooms addObject:[oneCustomer objectForKey:@"rooms"]];
NSLog(@"TET %@",_rooms);
[_washroom addObject:[oneCustomer objectForKey:@"bathrooms"]];
NSLog(@"TET %@",_washroom);
[_floor addObject:[oneCustomer objectForKey:@"floors"]];
NSLog(@"TET %@",_floor);
[_type addObject:[oneCustomer objectForKey:@"price"]];
NSLog(@"TET %@",_type);
[_descrip addObject:[oneCustomer objectForKey:@"property_description"]];
NSLog(@"TET %@",_descrip);
[_LandArea addObject:[oneCustomer objectForKey:@"land_area"]];
NSLog(@"TET %@",_LandArea);
[_Id addObject:[oneCustomer objectForKey:@"property_id"]];
NSLog(@"TET %@",_Id);
[_location addObject:[oneCustomer objectForKey:@"location"]];
NSLog(@"TET %@",_location);
}
dispatch_async(dispatch_get_main_queue(), ^{
// This code will run once the JSON-loading section above has completed.
[self.tableView reloadData];
});
NSString *status=[dictionary valueForKey:@"property_data"];
NSLog(@"Status:%@",status);
}
else{
NSLog(@"network error:");
}
}];
[dataTask resume];
}
請和你的問題粘貼相關的代碼。 –
請不要發佈完整的代碼..只是發佈代碼不工作的部分你認爲 –
其實我寫的函數是在viewdidload函數中加載。現在我問我是否在這個或之前寫入了inicator startanimation。 @TusharSharma –