iOS Obj-C - UITableView data disappears when modal view dismissed - ios

I have a uitableview inside of a view controller, and a button underneath of my uitableview. Tapping this button opens a modal view. I've created a "close" button inside my modal using the following code:
modalview.m
- (IBAction)closeButton:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
However when I tap to dismiss my modal view, all of the data in my uitableview seems to disappear (the uitableview just goes white)? Any idea why this might be, and how can I fix it? Here is how my tableview data is loaded and structured (hope this helps):
ViewController.m
-(void)updateMessages {
self.tableView.dataSource = self;
NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:#"name" forKey:#"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.messages = (NSMutableArray *)responseObject;
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Failure: %#", [error localizedDescription]);
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self updateMessages];
static NSString *ChatTableIdentifier = #"ChatTableViewCell";
static NSString *ChatTableIdentifier2 = #"SwapDetailTableViewCell";
UINib *nib = [UINib nibWithNibName: ChatTableIdentifier bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier: ChatTableIdentifier];
UINib *nib2 = [UINib nibWithNibName: ChatTableIdentifier2 bundle:nil];
[self.tableView registerNib:nib2 forCellReuseIdentifier: ChatTableIdentifier2];
self.tableView.dataSource = self;
[self.tableView reloadData];
}
- (int)numberOfSectionsInTableView: (UITableView *)tableview
{
return 1;
}
- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.messages count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *data = self.messages[indexPath.row];
id swaptime = data[#"swaptime"];
if ([swaptime isKindOfClass:[NSString class]]) {
// There is a valid "swaptime" value
static NSString *ChatTableIdentifier2 = #"SwapDetailTableViewCell";
SwapDetailTableViewCell *cell = (SwapDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ChatTableIdentifier2 forIndexPath:indexPath];
NSString *time = data[#"swaptime"];
cell.startTime.text = time;
NSString *timeEnd = data[#"endswaptime"];
cell.endTime.text = timeEnd;
NSString *costofSwap = data[#"swapvalue"];
cell.swapValue.text = costofSwap;
NSString *fromUsername = data[#"first name"];
cell.fromUser.text = fromUsername;
NSString *pet = data[#"pet's name"];
cell.petsname.text = pet;
NSString *swapStatus = data[#"swapaccepted"];
if ([swapStatus isEqual: #"Yes"]) {
[cell.displayedBar setImage:[UIImage imageNamed:#"greenbar.png"]];
cell.swapTitle.text = #"Accepted!";}
else {
if ([swapStatus isEqual: #""]) {
[cell.displayedBar setImage:[UIImage imageNamed:#"orangecellbar.png"]];
cell.swapTitle.text = #"You have a Request!";}
if ([swapStatus isEqual: #"Requested"]) {
[cell.displayedBar setImage:[UIImage imageNamed:#"orangecellbar.png"]];
cell.swapTitle.text = #"You have a Request!";}
if ([swapStatus isEqual: #"Cancelled"]) {
[cell.displayedBar setImage:[UIImage imageNamed:#"blueecellbar.png"]];
cell.swapTitle.text = #"Cancelled!";}
if ([swapStatus isEqual: #"No"]) {
[cell.displayedBar setImage:[UIImage imageNamed:#"redbar.png"]];
cell.swapTitle.text = #"Declined!";
}
}
return cell;
} else {
static NSString *ChatTableIdentifier = #"ChatTableViewCell";
ChatTableViewCell *cell = (ChatTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ChatTableIdentifier forIndexPath:indexPath];
NSString *userName = data[#"first name"];
cell.sendingUser.text = userName;
NSString *messageBody = data[#"body"];
cell.messageDisplayed.text = messageBody;
NSString *timeReceived = data[#"published at"];
cell.timeStamp.text = timeReceived;
NSString *userInfo = [self.userid objectForKey:#"first name"];
if ([cell.sendingUser.text isEqual: userInfo]) {
cell.messageDisplayed.textAlignment = NSTextAlignmentLeft;
cell.sendingUser.textAlignment = NSTextAlignmentLeft;
[cell.chatBubble setImage:[UIImage imageNamed:#"bubblegrey2.png"]];
} else {
cell.messageDisplayed.textAlignment = NSTextAlignmentRight;
cell.sendingUser.textAlignment = NSTextAlignmentRight;
[cell.chatBubble setImage:[UIImage imageNamed:#"bubbleorange2.png"]];
}
return cell;
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
}

The problem is probably in your viewDidAppear, try replace:
[self.tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
with:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[self.messages count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
or properly calculate the height, probably it's:
self.tableView.contentView.height

Related

how to plus and minus when button is clicked in uitabelview row and section and reload like foodpanda

I am creating app link food panda.let me explain the flow.I have a vc with table with rows and sections when i click on section it will expand and collapsing rows.in the section there is add button in each rows.wqhen i click on add button in section 3 row the button should hide and + and - button should show like the image given below.
2.when i click on the pluse and minus button it should add to cart and money should increase and decrease amount in cart i used below code for expand and collapse sections.
#implementation menulistingVC
- (void)viewDidLoad {
[super viewDidLoad];
[super viewDidLoad];
menuarray=[[NSMutableArray alloc]init];
arrselectedrow=[[NSMutableArray alloc]init];
defaults = [NSUserDefaults standardUserDefaults];
apiCall = [[APICall alloc]init];
isMultipleExpansionAllowed = NO;
arrSelectedSectionIndex = [[NSMutableArray alloc] init];
if (!isMultipleExpansionAllowed) {
[arrSelectedSectionIndex addObject:[NSNumber numberWithInt:countt+20]];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(loadtable:)
name:#"array" object:nil];
_tblview.estimatedRowHeight = 69;
_tblview.rowHeight = UITableViewAutomaticDimension;
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)loadtable:(NSNotification*)notification
{
isMultipleExpansionAllowed = NO;
arrSelectedSectionIndex = [[NSMutableArray alloc] init];
if (!isMultipleExpansionAllowed) {
[arrSelectedSectionIndex addObject:[NSNumber numberWithInt:countt+20]];
}
[self getingfooddeatilsbacedonclub:[notification object]];
}
-(void)getingfooddeatilsbacedonclub:(NSString *)typestr{
_clubstr = [[NSUserDefaults standardUserDefaults]
stringForKey:#"newclubid"];
// accessToken=[defaults valueForKey:#"accessToken"];
// clubberId = [defaults valueForKey:#"idClubber_dtls"];
if (![APICall hasNetwork])
{
[Util displayToastMessage:#"No internet connection"];
}else
{
[customBezelActivityView activityViewForView:self.view];
NSString *urlstr = [NSString stringWithFormat:#"%s/presignin/menu/list/category/by_venue?clubId=%#&type=%#",urlPath,_clubstr,typestr];
NSLog(#"getherd :%#",urlstr);
[apiCall getArrayFromApiwithstauscode:urlstr restfulType:kRestfulGet andUseContentType:NO withRequestBody:nil completionHandler:^(NSArray *result, NSInteger statuscodeint){
NSLog(#"classifieds List response:%#",result);
NSLog(#"statuscode List response:%ld",(long)statuscodeint);
if (statuscodeint==200) {
dispatch_async(dispatch_get_main_queue(), ^{
[customBezelActivityView removeViewAnimated:YES];
menuarray=[result mutableCopy];
isMultipleExpansionAllowed = NO;
if (!isMultipleExpansionAllowed) {
[arrSelectedSectionIndex addObject:[NSNumber numberWithInt:countt+20]];
}
[_tblview reloadData];
});
}else if (statuscodeint==401){
dispatch_async(dispatch_get_main_queue(), ^{
[customBezelActivityView removeViewAnimated:YES];
UIStoryboard *storyBoard =[UIStoryboard storyboardWithName:#"Main" bundle:nil];
SignInViewController *SignINViewController=[storyBoard instantiateViewControllerWithIdentifier:#"SignINViewController"];
[self presentViewController:SignINViewController animated:YES completion:nil];
});
}
}];
}
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return menuarray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([arrSelectedSectionIndex containsObject:[NSNumber numberWithInteger:section]])
{
NSArray *arr=[menuarray[section] valueForKey:#"menu"];
return arr.count;
}else{
return 0;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"MenudetailsTblCell";
menudetailscell = ( MenudetailsTblCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (menudetailscell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"MenudetailsTblCell" owner:self options:nil];
menudetailscell = [nib objectAtIndex:0];
}
if (menudetailscell == nil)
{
menudetailscell = [[MenudetailsTblCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
menudetailscell.detailview.layer.cornerRadius = 3.0;
menudetailscell.detailview.layer.masksToBounds = YES;
if (indexPath.row==0) {
menudetailscell.toplbl.hidden=YES;
}else{
menudetailscell.toplbl.hidden=NO;
}
menudetailscell.addbtntocart.layer.cornerRadius = 5.0;
menudetailscell.addbtntocart.layer.masksToBounds = YES;
menudetailscell.addbtntocart.tag=indexPath.row;
menudetailscell.plusebtn.tag=indexPath.row;
menudetailscell.minusbtn.tag=indexPath.row;
menudetailscell.plusebtn.hidden=YES;
menudetailscell.minusbtn.hidden=YES;
menudetailscell.noofitemslbl.hidden=YES;
NSArray *arr=[menuarray[indexPath.section] valueForKey:#"menu"];
menudetailscell.typelbl.text=[[arr objectAtIndex:indexPath.row]valueForKey:#"name"];
menudetailscell.describtionlbl.text=[[arr objectAtIndex:indexPath.row]valueForKey:#"description"];
NSString *cost=[NSString stringWithFormat:#"%#%#",[[arr objectAtIndex:indexPath.row]valueForKey:#"price"],#".00"];
NSString *imgid=[NSString stringWithFormat:#"%#",[[arr objectAtIndex:indexPath.row]valueForKey:#"idmenus"]];
NSString *tax=[NSString stringWithFormat:#"%#",[[arr objectAtIndex:indexPath.row]valueForKey:#"tax"]];
if ([tax isEqualToString:#"tax"]) {
menudetailscell.taxlbl.text=#"(*Inclusive of all taxes)";
}else{
menudetailscell.taxlbl.text=#"(*Exclusive of all taxes)";
}
menudetailscell.ratelbl.text=[NSString stringWithFormat:#"%# %#",[[arr objectAtIndex:indexPath.row]valueForKey:#"country"],cost];
[ menudetailscell.addbtntocart addTarget:self action:#selector(addbtnclicked:)forControlEvents:UIControlEventTouchUpInside];
NSString *typeimgUrl1 = [NSString stringWithFormat:#"%s/presignin/menu/showMedia?idMenu=%#",urlPath,imgid];
NSURL *imageURL=[NSURL URLWithString:typeimgUrl1];
menudetailscell.imgview.imageURL=imageURL;
[menudetailscell.plusebtn addTarget:self action:#selector(pluseTapShowHideSection:) forControlEvents:UIControlEventTouchUpInside];
[menudetailscell.minusbtn addTarget:self action:#selector(minusTapShowHideSection:) forControlEvents:UIControlEventTouchUpInside];
menudetailscell.selectionStyle = UITableViewCellSelectionStyleNone;
return menudetailscell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *CellIdentifier = #"Menusectioncell";
menusectioncell = ( Menusectioncell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (menusectioncell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"Menusectioncell" owner:self options:nil];
menusectioncell = [nib objectAtIndex:0];
}
if (menusectioncell == nil)
{
menusectioncell = [[Menusectioncell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if ([arrSelectedSectionIndex containsObject:[NSNumber numberWithInteger:section]])
{
// right-arrow //down-arrow
menusectioncell.Sectiomtitlebtn.selected = YES;
menusectioncell.dotlbl.hidden=NO;
menusectioncell.expandtypeimg.image=[UIImage imageNamed:#"down-arrow"];
}
else{
menusectioncell.dotlbl.hidden=YES;
menusectioncell.expandtypeimg.image=[UIImage imageNamed:#"right-arrow"];
}
menusectioncell.Sectiomtitlebtn.tag=section;
menusectioncell.dotlbl.layer.cornerRadius = menusectioncell.dotlbl.frame.size.height/2;
menusectioncell.dotlbl.layer.masksToBounds = YES;
[menusectioncell.Sectiomtitlebtn addTarget:self action:#selector(btnTapShowHideSection:) forControlEvents:UIControlEventTouchUpInside];
NSString *btntitle=[menuarray[section] valueForKey:#"catagory"];
itemarr=[menuarray[section] valueForKey:#"menu"];
NSString *items=[itemarr[0] valueForKey:#"name"];
menusectioncell.sectiontitleilb.text=btntitle;
if (itemarr.count==1) {
menusectioncell.itemslbl.text=[NSString stringWithFormat:#"%#",items];
}else{
NSString *seconditemstr=[itemarr[1] valueForKey:#"name"];
menusectioncell.itemslbl.text=[NSString stringWithFormat:#"%#,%# etc..",items,seconditemstr];
}
menusectioncell.selectionStyle = UITableViewCellSelectionStyleNone;
return menusectioncell.contentView;
}
-(IBAction)btnTapShowHideSection:(UIButton*)sender
{
int section=sender.tag;
if (!sender.selected)
{
//originallcode
if (!isMultipleExpansionAllowed) {
[arrSelectedSectionIndex addObject:#"-1"];
[arrSelectedSectionIndex replaceObjectAtIndex:0 withObject:[NSNumber numberWithInteger:sender.tag]];
}else {
NSLog(#"%#",arrSelectedSectionIndex);
[arrSelectedSectionIndex addObject:[NSNumber numberWithInteger:sender.tag]];
}
menusectioncell.dotlbl.hidden=YES;
menusectioncell.expandtypeimg.image=[UIImage imageNamed:#"right-arrow"];
sender.selected = YES;
}
else{
sender.selected = NO;
menusectioncell.dotlbl.hidden=NO;
menusectioncell.expandtypeimg.image=[UIImage imageNamed:#"down-arrow"];
if ([arrSelectedSectionIndex containsObject:[NSNumber numberWithInteger:sender.tag]])
{
[arrSelectedSectionIndex removeObject:[NSNumber numberWithInteger:sender.tag]];
}
}
if (!isMultipleExpansionAllowed) {
[_tblview reloadData];
}else {
[_tblview reloadSections:[NSIndexSet indexSetWithIndex:sender.tag] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
- (void)addbtnclicked:(UIButton *)sender
{
menudetailscell.plusebtn.hidden=NO;
menudetailscell.minusbtn.hidden=NO;
menudetailscell.noofitemslbl.hidden=NO;
menudetailscell.addbtntocart.hidden=YES;
int rowselect=sender.tag;
[arrselectedrow addObject:[NSNumber numberWithInteger:sender.tag]];
NSIndexPath* indexPath1 = [NSIndexPath indexPathForRow:sender.tag inSection:sectionselect];
[self.tblview beginUpdates];
[self.tblview reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath1, nil] withRowAnimation:UITableViewRowAnimationNone];
[self.tblview endUpdates];
}
- (void)pluseTapShowHideSection:(UIButton *)sender
{
}
- (void)minusTapShowHideSection:(UIButton *)sender
{
if ([arrselectedrow containsObject:[NSNumber numberWithInteger:sender.tag]])
{
[arrselectedrow removeObject:[NSNumber numberWithInteger:sender.tag]];
}
[self.tblview beginUpdates];
[self.tblview reloadRowsAtIndexPaths:[NSArray arrayWithObjects:arrselectedrow, nil] withRowAnimation:UITableViewRowAnimationNone];
[self.tblview endUpdates];
}

How to resolve when UITableview is double open on same page

I have 2 UITableView. On first UITableView make for search and select cell. After selected cell from UITableView1. It's will show blank data of UITableView2 and show new UITableView2 again with data.
I'm sorry for my bad english language.
I can speak english a little bit.
If you don't understand my question.
Please follow to see pictures below here.
First UITableView: (Click button for go to second UITableView.)
After click button. UITableView2 show blank data.
And auto show new UITableView2 with data again.
UITableView1
#interface SearchByContainerDetailViewController ()
#property (weak, nonatomic) IBOutlet UITableView *tableViewWhereHoseList;
#end
#implementation SearchByContainerDetailViewController
#synthesize labelName,strName,txResult,strResult,labelStatus;
NSString *selectedWhereHouse;
GlobalVariable *gloablOnWherehouse;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
labelName.text = strName;
//txResult.text = strResult;
labelStatus.text = #"NULL";
gloablOnWherehouse = [GlobalVariable sharedInstance];
gloablOnWherehouse.arTableDataSelectedWhereHouse = [[NSArray alloc] init];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (gloablOnWherehouse.arTableDataSelected)?[gloablOnWherehouse.arTableDataSelected count]:1;
}
- (NSInteger) tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"%lu", (unsigned long)[gloablOnWherehouse.arTableDataSelected count]);
return (gloablOnWherehouse.arTableDataSelected)?[gloablOnWherehouse.arTableDataSelected count]:1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"SearchByContainerDetailViewCell";
SearchByContainerDetailViewCell *cell = [self.tableViewWhereHoseList dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"SearchByContainerDetailViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
} else {
if (gloablOnWherehouse.arTableDataSelected) {
NSMutableArray *myMutbleArray = [[NSMutableArray alloc] init];
[myMutbleArray addObject:gloablOnWherehouse.arTableDataSelected];
if (myMutbleArray) {
NSDictionary *myDic = [gloablOnWherehouse.arTableDataSelected objectAtIndex:indexPath.row];
NSDictionary *cont = [myDic objectForKey:#"DataList_SPI_Detail"];
NSString *date = [self getString:[cont objectForKey:#"date"]];
NSString *qty = [self getString:[cont objectForKey:#"qty"]];
NSString *stock = [self getString:[cont objectForKey:#"stock"]];
NSString *ord = [self getString:[cont objectForKey:#"ord"]];
NSString *custmr = [self getString:[cont objectForKey:#"custmr"]];
NSString *remarks = [self getString:[cont objectForKey:#"remarks"]];
NSString *invoice = [self getString:[cont objectForKey:#"invoice"]];
NSString *due = [self getString:[cont objectForKey:#"due"]];
NSString *lot = [self getString:[cont objectForKey:#"lot"]];
NSString *gap = [self getString:[cont objectForKey:#"gap"]];
[cell setDate:date setQty:qty setStock:stock setOrd:ord setCustmr:custmr setRemarks:remarks setInvoice:invoice setDue:due setLot:lot setGap:gap];
}
}
}
return cell;
}
- (void) requestEWIServiceFinish:(EWIConnector *)connector responseData:(NSDictionary *)responseData{
NSLog(#"finish %#",connector.serviceName);
NSLog(#"response %#",responseData);
if ([connector.serviceName isEqualToString:#"special_selected_f10"])
{
NSLog(#"finish %#",connector.serviceName);
NSDictionary *content = responseData[#"content"];
NSString *stAlertMes = [content objectForKey:#"alertMessage"];
stAlertMes = [self getString:stAlertMes];
NSLog(#"AlertMSG : %#", stAlertMes);
if (![stAlertMes isEqualToString:#""]) {
NSLog(#"ALERT MESSAGE : %#", stAlertMes);
gloablOnWherehouse.arTableDataSelected = [[NSArray alloc] init];
}
else
{
NSLog(#"HAS DATA");
gloablOnWherehouse.arTableDataSelected = [content objectForKey:#"DataList_SPI_DetailCollection"];
[self.tableViewWhereHoseList reloadData];
labelStatus.text = #"F11";
}
}
else
{
NSLog(#"response %#",responseData);
}
}
- (void) requestEWIServiceFail:(EWIConnector *)connector error:(NSError *)error{
NSLog(#"request fail %#",connector);
}
- (NSString *)getString:(NSString *)string
{
return [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (IBAction)btnf10
{
NSMutableDictionary *content = [NSMutableDictionary dictionary];
[content setValue:[[AppSetting sharedInstance] token] forKey:#"ewitoken"];
//[content setValue:gloablOnWherehouse.selectedWhereHouse forKey:#"model_Name"];
[[EWIConnector connector] requestEWIService:#"special_selected_f10" requestData:content delegate:self];
}
UITableView2
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
globlOnDisplayEffect = [GlobalVariable sharedInstance];
globlOnDisplayEffect.arTableDataSelectedWhereHouse = [[NSArray alloc] init];
[self.tableViewDetailList reloadData];
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return (globlOnDisplayEffect.arTableDataSelected)?[globlOnDisplayEffect.arTableDataSelected count]: 1;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = #"DisplayEffectQtyViewCell";
DisplayEffectQtyViewCell *cell = [self.tableViewDetailList dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];
if(cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"DisplayEffectQtyViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
} else {
if (globlOnDisplayEffect.arTableDataSelected) {
NSMutableArray *myMutbleArray = [[NSMutableArray alloc] init];
[myMutbleArray addObject:globlOnDisplayEffect.arTableDataSelected];
if (myMutbleArray) {
NSDictionary *myDic = [globlOnDisplayEffect.arTableDataSelected objectAtIndex:indexPath.row];
NSDictionary *cont = [myDic objectForKey:#"DataList_SPI_DetailF10"];
NSString *f10_cmpt = [self getString:[cont objectForKey:#"f10_cmpt"]];
NSString *f10_dt = [self getString:[cont objectForKey:#"f10_dt"]];
NSString *f10_item = [self getString:[cont objectForKey:#"f10_item"]];
NSString *f10_lot = [self getString:[cont objectForKey:#"f10_lot"]];
NSString *f10_model = [self getString:[cont objectForKey:#"f10_model"]];
NSString *f10_of = [self getString:[cont objectForKey:#"f10_of"]];
NSString *f10_semi = [self getString:[cont objectForKey:#"f10_semi"]];
NSString *f10_tm = [self getString:[cont objectForKey:#"f10_tm"]];
NSString *f10_uncmp = [self getString:[cont objectForKey:#"f10_uncmp"]];
[cell setf10_cmpt:f10_cmpt setf10_dt:f10_dt setf10_item:f10_item setf10_lot:f10_lot setf10_model:f10_model setf10_of:f10_of setf10_semi:f10_semi setf10_tm:f10_tm setf10_uncmp:f10_uncmp];
}
}
}
return cell;
}
- (void) requestEWIServiceStart:(EWIConnector *)connector{
NSLog(#"start %#",connector.endpoint);
}
TO Check if view controller already push or not.
if(![self.navigationController.topViewController isKindOfClass:[NewViewController class]]) {
[self.navigationController pushViewController:newViewController animated:YES];
}

Table view cells showing actual data only after scrolling once

NSArray *sectionArray;
int sectionCount=0;
NSDictionary *orderedData;
NSString *checkInStr, *checkOutStr;
NSString *govtTaxes, *enhancementTotal, *grandTotal;
- (void)viewDidLoad {
[super viewDidLoad];
[self setupTable];
[self.bookingsTableView reloadData];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)viewDidDisappear:(BOOL)animated {
if(doesSendNotification){
NSLog(#"summary view disappeared");
[[NSNotificationCenter defaultCenter] postNotificationName:#"SummaryViewDismissedNotification" object:self];
}
}
-(void)viewWillAppear:(BOOL)animated {
[self.bookingsTableView reloadData];
}
-(void)setupTable {
self.bookingsTableView.rowHeight = UITableViewAutomaticDimension;
self.bookingsTableView.estimatedRowHeight = 50.0;
sectionArray = [[SummaryModel sharedInstance] getTableSections:self.s_sendEnhancementServerDict];
orderedData = [[SummaryModel sharedInstance] getOrderedData:self.s_sendEnhancementServerDict];
[self.bookingsTableView reloadData];
}
#pragma mark- UITableview delegate and datasource methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(section==0){
return 3;
} else if (section>0 && section<(sectionCount-1)){
int rows=(int)[[orderedData objectForKey:(NSString*)[sectionArray objectAtIndex:section]] count];
return rows;
} else {
return 4;
}
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return (NSString*)[sectionArray objectAtIndex:section];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier;
UITableViewCell *cell;
// UITableView *table = (UITableView*)[self.view viewWithTag:11];
if (indexPath.section==0 && indexPath.row>=0 && indexPath.row<=2) {
cellIdentifier =#"SplitCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
UILabel *l1 = (UILabel*)[cell viewWithTag:1];
UILabel *l2 = (UILabel*)[cell viewWithTag:2];
if(indexPath.row==0){
l1.attributedText = [self getStyledString1:#"Hotel Name"];
l2.attributedText = [self getStyledString:self.s_propertyName];
} else if(indexPath.row==1){
l1.attributedText = [self getStyledString1:#"Arrival Date:"];
l2.attributedText = [self getStyledString:checkInStr];
} else if(indexPath.row==2){
l1.attributedText = [self getStyledString1:#"Departure Date:"];
l2.attributedText = [self getStyledString:checkOutStr];
}
} else if (indexPath.section>0 && indexPath.section<(sectionCount-1)) {
// for(int i=0;i<5;i++){
cellIdentifier=#"VerticalLabelCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
UILabel *l3 = (UILabel*)[cell viewWithTag:3];
UILabel *l4 = (UILabel*)[cell viewWithTag:4];
l3.layer.backgroundColor = GOLDEN_COLOR.CGColor;
NSArray *roomTypeArray = [orderedData objectForKey:(NSString*)[sectionArray objectAtIndex:indexPath.section]];
NSDictionary *roomD = [roomTypeArray objectAtIndex:indexPath.row];
NSString *header = [roomD objectForKey:#"room_type_name"];
NSAttributedString *sH = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:#" %#",header] attributes:#{NSFontAttributeName:ARIAL_FONT_BOLD}];
l3.attributedText = sH;
int roomCount = [(NSNumber*)[roomD objectForKey:#"room_units"] intValue];
NSMutableAttributedString *labelText = [[NSMutableAttributedString alloc] init];
for(int i=0;i<roomCount;i++){
NSString *roomNo = [NSString stringWithFormat:#"\n Room # %d\n",i+1];
NSAttributedString *s = [[NSAttributedString alloc] initWithString:roomNo attributes:#{NSFontAttributeName:ARIAL_FONT_BOLD, NSUnderlineStyleAttributeName:#(NSUnderlineStyleSingle)}];
[labelText appendAttributedString:s];
NSString *adults = [NSString stringWithFormat:#" Adults: %# \t\t Max. Adults: %# \n",[roomD objectForKey:#"max_adults"],[roomD objectForKey:#"max_adults"]];
NSAttributedString *s1 = [[NSAttributedString alloc] initWithString:adults attributes:#{NSFontAttributeName:ARIAL_FONT_BOLD}];
[labelText appendAttributedString:s1];
NSArray *enhanc = [(NSArray*)[roomD objectForKey:#"room_features"] objectAtIndex:i];
for(int i=0;i<[enhanc count];i++){
[labelText appendAttributedString:[self getStyledString2:[NSString stringWithFormat:#" %#\n", [enhanc objectAtIndex:i]]]];
}
l4.attributedText = labelText;
}
} else if(indexPath.section==(sectionCount-1)){
cellIdentifier =#"SplitCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
UILabel *l1 = (UILabel*)[cell viewWithTag:1];
UILabel *l2 = (UILabel*)[cell viewWithTag:2];
if(indexPath.row==0){
l1.attributedText = [self getStyledString1:#"Room Charges:"];
l2.attributedText = [self getStyledString:[NSString stringWithFormat:#"£ %#", self.s_priceOfRooms]];
}else if(indexPath.row==1){
l1.attributedText = [self getStyledString1:#"Government Taxes:"];
l2.attributedText = [self getStyledString:[NSString stringWithFormat:#"£ %#", govtTaxes]];
}else if(indexPath.row==2){
l1.attributedText = [self getStyledString1:#"Enhancement Total:"];
l2.attributedText = [self getStyledString:[NSString stringWithFormat:#"£ %#", enhancementTotal]];
}else if(indexPath.row==3){
l1.attributedText = [self getStyledString1:#"Total Charges"];
l2.attributedText = [self getStyledString:[NSString stringWithFormat:#"£ %#", grandTotal]];
}
}
return cell;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
sectionCount = (int)[sectionArray count];
return sectionCount;
}
-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
view.tintColor = GOLDEN_COLOR;
}
-(NSAttributedString*)getStyledString:(NSString*)input {
NSAttributedString *str = [[NSAttributedString alloc] initWithString:input attributes:#{NSForegroundColorAttributeName:GOLDEN_COLOR, NSFontAttributeName:ARIAL_FONT}];
return str;
}
-(NSAttributedString*)getStyledString1:(NSString*)input {
NSAttributedString *str = [[NSAttributedString alloc] initWithString:input attributes:#{NSFontAttributeName:ARIAL_FONT_BOLD}];
return str;
}
-(NSAttributedString*)getStyledString2:(NSString*)input {
NSAttributedString *str = [[NSAttributedString alloc] initWithString:input attributes:#{NSFontAttributeName:ARIAL_FONT}];
return str;
}
I have made a ViewController and added a table view in it. Some data is populated in cells and then displayed.
When I run it, initially I don't see any data in my cells. But when the tableview is scrolled cells start showing the actual data. I don't understand what could be the reason. Any pointers please???
I want to dynamically resize my cells as data can be of random size. Data shows only after scrolling once.
This problem is related to using UITableViewAutomaticDimension and has been reported at other places as well. So this line of code, solved my problem:
-(void)viewDidAppear:(BOOL)animated {
[self.tableView reloadData];
}
This just reloads all the table sections and rows before displaying. So user does not experience blank rows. Refer: http://www.appcoda.com/self-sizing-cells/
You need to use reloadData in the main thread (viewDidLoad). You need to use
dispatch_async like the code below :
dispatch_async(dispatch_get_main_queue(), ^{
[self.mytable reloadData];
}
In setupTable, check sectionArray and orderedData to make sure they're not empty. Add an assertion in setupTable, e.g.,
sectionArray = [[SummaryModel sharedInstance] getTableSections:self.s_sendEnhancementServerDict];
orderedData = [[SummaryModel sharedInstance] getOrderedData:self.s_sendEnhancementServerDict];
NSAssert([sectionArray count] && [orderedData count], #"No data!"); // add this line
[self.bookingsTableView reloadData];
Swift 5+
IOS 13
Xcode 11.2.1 +
Amazing Answer
override func viewDidAppear(_ animated: Bool) {
// self.tablev.frame.origin.y = vnavigation.frame.maxY + 5
// tablevheight = self.tablev.frame.size.height
self.bgview.backgroundColor = UIColor.init(patternImage: UIImage(named: "chat_bg.png")!)
self.registerForKeyboardNotifications()
UIView.performWithoutAnimation {
tablev.beginUpdates()
tablev.endUpdates()
}
}

iOS Parse UISearchBar

I am new to iOS. I am making an app in which i am getting data from Parse back-end all are working fine.
I did UISearchbar and it works well. But when a search produces more than 6 results (main table have 6 rows, but I search for another Parse class) , this leads to an error.
2015-06-09 14:10:23.318 Aero store[3238:347073] Terminating app due to uncaught exception 'NSRangeException', reason: '
-[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
This is my code:
#import "CategoryTable.h"
#import "GoodsTable.h"
#import "Parse/Parse.h"
#interface CategoryTable ()<UISearchDisplayDelegate, UISearchBarDelegate>
#property (nonatomic, strong) UISearchDisplayController *searchController;
#property (nonatomic, strong) NSMutableArray *searchResults;
#end
#implementation CategoryTable
#synthesize categoryId;
- (void)viewDidLoad {
[super viewDidLoad];
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.goodsSearchBar contentsController:self];
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.searchController.delegate = self;
[self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:#"menu-background"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
CGPoint offset = CGPointMake(0, self.goodsSearchBar.frame.size.height);
self.tableView.contentOffset = offset;
self.searchResults = [NSMutableArray array];
self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#" " style:UIBarButtonItemStylePlain target:nil action:nil];
if ([[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"] != nil) {
//Город установлен - > категории
NSLog(#"Gorod - %#", [[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"]);
//[self performSegueWithIdentifier:#"showCategory" sender:self];
}
else
{
//Город не установлен -> выбор города
NSLog(#"Gorod - %#", [[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"]);
}
//Установка лого
UIView *headerView = [[UIView alloc] init];
headerView.frame = CGRectMake(0, 0, 151, 20);
UIImageView *logoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"logo"]];
logoImage.frame = CGRectMake(0, 0, 151, 20);
logoImage.contentMode = UIViewContentModeScaleAspectFit;
[headerView addSubview:logoImage];
[self.navigationItem setTitleView:headerView];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
self.parseClassName = #"Category";
self.pullToRefreshEnabled = NO;
self.paginationEnabled = NO;
}
return self;
}
//Слово для поиска
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
searchString = [searchString lowercaseString];
[self filterResults:searchString];
return NO;
}
//Запрос для поиска
-(void)filterResults:(NSString *)searchTerm {
if (searchTerm.length > 1) {
[PFCloud callFunctionInBackground:#"find"
withParameters:#{#"goodsName": searchTerm, #"city":[[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"]}
block:^(NSArray *goodsList, NSError *error) {
if (!error) {
NSLog(#"Найдено: %#",goodsList);
[self.searchResults removeAllObjects];
[self.searchResults addObjectsFromArray:goodsList];
dispatch_async(dispatch_get_main_queue(), ^{
[self.searchController.searchResultsTableView reloadData];
});
}
}];
}
}
//Получени списка категорий
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query whereKey:#"cityName" equalTo:[[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"]];
if (self.objects.count == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByAscending:#"createdAt"];
return query;
}
//Количество ячеек для результата поиска
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView) {
return self.searchResults.count;
}
else {
return self.objects.count;
}
}
//Обрезка пустых ячеек
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *sectionFooterView = [[UIView alloc] initWithFrame:
CGRectMake(0, 0, tableView.frame.size.width, 1)];
sectionFooterView.backgroundColor = [UIColor clearColor];
return sectionFooterView;
}
//Отрисовка ячеек категорий
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *identifier = #"categoryCell";
PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (tableView == self.tableView) {
UILabel *titleLabel = (UILabel*) [cell viewWithTag:200];
titleLabel.text = [object objectForKey:#"title"];
PFFile *thumbnail = [object objectForKey:#"image"];
PFImageView *catImageView = (PFImageView*)[cell viewWithTag:100];
catImageView.image = [UIImage imageNamed:#"placeholder"];
catImageView.file = thumbnail;
[catImageView loadInBackground];
}
else if(tableView == self.searchDisplayController.searchResultsTableView) {
NSLog(#"test");
PFObject *searchedUser = [self.searchResults objectAtIndex:indexPath.row];
cell.textLabel.text = [[searchedUser objectForKey:#"name"] capitalizedString];
}
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showGoods"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
GoodsTable *goods= segue.destinationViewController;
PFObject *object = [self.objects objectAtIndex:indexPath.row];
categoryId = [object objectForKey:#"title"];
NSLog(#"Category Name = %#", categoryId);
goods.cityName = [[NSUserDefaults standardUserDefaults] objectForKey:#"cityName"];
goods.categoryId = categoryId;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#end
Please help me! I can not solve the problem for several days. :'(
Try
dispatch_async(dispatch_get_main_queue(), ^{
[self.searchResults removeAllObjects];
[self.searchResults addObjectsFromArray:goodsList];
[self.searchController.searchResultsTableView reloadData];
});
to ensure editing your datasource and reloading your tablew view are done in the same dispatch queue.

UISearchDisplayController the results are delayed by 3-6secs

When I type letters into my Search I get lag for about 4secs and can`t do anything. Everything others work good. UISearchDisplayController find me what I want, segue works good . I am not sure if it is about memory or some mistake in my code. Can anyone help me? Thanks
My code
TableViewController.m
#implementation TableViewController
#synthesize colorsTable;
#synthesize searchBar;
#synthesize searchController;
#synthesize searchResults;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showDetail"]) {
{
DetailViewController *sdvc = (DetailViewController *)[segue destinationViewController];
if(self.searchDisplayController.active) {
NSIndexPath *indexPath = [[self tableView] indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
object = (PFObject *)[[self searchResults]objectAtIndex:[[[[self searchDisplayController]searchResultsTableView]indexPathForSelectedRow]row]];
sdvc.detailItem = object;
} else {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
DetailViewController *detailViewController = [segue destinationViewController];
detailViewController.detailItem = object;
}
}
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:#selector(runThisMethod) withObject:nil afterDelay:1.9f];
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
self.tableView.tableHeaderView = self.searchBar;
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.searchController.delegate = self;
CGPoint offset = CGPointMake(0, self.searchBar.frame.size.height);
self.tableView.contentOffset = offset;
self.searchResults = [NSMutableArray array];
-(void)filterResults:(NSString *)searchTerm {
[self.searchResults removeAllObjects];
PFQuery *query = [PFQuery queryWithClassName: self.parseClassName];
[query whereKeyExists:#"MestoName"]; //this is based on whatever query you are trying to accomplish
[query whereKey:#"MestoName" containsString:searchTerm];
NSArray *results = [query findObjects];
NSLog(#"%#", results);
NSLog(#"%u", results.count);
[self.searchResults addObjectsFromArray:results];
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self filterResults:searchString];
return YES;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.tableView) {
//if (tableView == self.searchDisplayController.searchResultsTableView) {
return self.objects.count;
} else {
return self.searchResults.count;
}
}
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
tableView.rowHeight = 90.0f;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *uniqueIdentifier = #"colorsCell";
CustomCell *cell = nil;
cell = (CustomCell *) [self.tableView dequeueReusableCellWithIdentifier:uniqueIdentifier];
[cell.imagevieww setImageWithURL:[NSURL URLWithString:[object objectForKey:#"ImageURL"]]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
cell.cellTitle.text = [object objectForKey:#"MestoName"];
cell.cellDescript.text = [object objectForKey:#"MestoSubname"];
if (!cell) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"colorsCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[CustomCell class]])
{
cell = (CustomCell *)currentObject;
break;
}
}
}
if (tableView == self.tableView) {
cell.cellTitle.text = [object objectForKey:#"MestoName"];
} else {
PFUser *obj2 = [self.searchResults objectAtIndex:indexPath.row];
PFQuery *query = [PFQuery queryWithClassName:#"Mesta"];
PFObject *searchedUser = [query getObjectWithId:obj2.objectId];
NSString *boottext = [searchedUser objectForKey:#"MestoName"];
cell.cellTitle.text = boottext;
NSString *bootsubtext = [searchedUser objectForKey:#"MestoSubname"];
cell.cellDescript.text = bootsubtext;
NSString *bootimage = [searchedUser objectForKey:#"ImageURL"];
[cell.imagevieww setImageWithURL:[NSURL URLWithString:bootimage]];
NSLog(#"Content: %#", boottext);
}
return cell;
}
#end
For everyone, who have the same problem. I have got already the solution. I rewrote all my code and it is finally working.
Here`s the code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
NSString *uniqueIdentifier = #"MainCell";
CustomCell3 *cell = nil;
cell = (CustomCell3 *) [self.tableView dequeueReusableCellWithIdentifier:uniqueIdentifier];
if (!cell) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"MainCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[CustomCell3 class]])
{
cell = (CustomCell3 *)currentObject;
break;
}
}
}
if (tableView == self.tableView) {
cell.MainTitle.text = [object objectForKey:#"CountryTitle"];
cell.DescriptTitle.text = [object objectForKey:#"DescriptTitle"];
[cell.FlagTitle setImageWithURL:[NSURL URLWithString:[object objectForKey:#"ImaURL"]]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
};
if(tableView == self.searchDisplayController.searchResultsTableView) {
PFObject *searchedUser = [self.searchResults objectAtIndex:indexPath.row];
NSString *content = [searchedUser objectForKey:#"CountryTitle"];
NSString *desco = [searchedUser objectForKey:#"DescriptTitle"];
cell.DescriptTitle.text = desco;
cell.MainTitle.text = content;
NSString *image = [searchedUser objectForKey:#"ImaURL"];
[cell.FlagTitle setImageWithURL:[NSURL URLWithString:image]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
};
return cell;
}

Resources