Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:12:41+00:00 2026-05-29T20:12:41+00:00

I am sorry for pasting a big chunk of code but i really want

  • 0

I am sorry for pasting a big chunk of code but i really want to get it work;
This app is supposed to be placing a UItableView on a screen.
Somehow this code is calling tableview methods twice and creating duplicate tables.

Do you have any suggestion what I can do to fix this behaviour?
Thanks in advance.

UITableView:

    - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
 NSLog(@"-------------numberOfRowsInSection---------------");
 NSLog(@"qtext =%d",[qtext count]);
return [qtext count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
{
return 1;
}

-(void)insertDeviders{
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
myLabel.text = @"About you";
[cell addSubview:myLabel];
}
//Return cellheight
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{

NSLog(@"-------------heightforrowatindexpath---------------"); 

dict = [qtext objectAtIndex:[indexPath row]];

NSDictionary  *dict2 = [qtype objectAtIndex:[indexPath row]];



type = [[dict2 allKeys] objectAtIndex:0]; 

NSString *text = [[dict allKeys] objectAtIndex:0]; 

CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height, 44.0f);


   thisheight= height + (CELL_CONTENT_MARGIN * 2) + 40;


   NSLog(@"thisheight=%d",thisheight);

NSString *q = [NSString stringWithFormat:@"%d", thisheight];   
[arrAllheight addObject:[NSString stringWithFormat:@"%@",q]];



if([type isEqualToString:@"devider"]){thisheight=28;}


NSLog(@"dict=%@",dict);
NSLog(@"thisheight=%d",thisheight);

return thisheight;



}

Populate cell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"-------------cellForRowAtIndexPath---------------");   

cell_id = [qid objectAtIndex:[indexPath row] ];       
static NSString *CellIdentifier = @"Cell";    
label = nil; 
 cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


//  if(![cell_id intValue]==0){     
dict = [qtext objectAtIndex:[indexPath row]];
celltext = [NSString stringWithFormat:@"%@\n\n\n",[[dict allKeys] objectAtIndex:0]];
dict = [qtype objectAtIndex:[indexPath row]];
type = [[dict allKeys] objectAtIndex:0];     

//place the question
cell.textLabel.text = celltext;  

  //  NSLog(@"row=%@",[indexpath row]);
    if([type isEqualToString:@"devider"]){      
        [self configureDevider];
    }else{
        [self configureCell];      
    }
    if([cell_id intValue] == ([qid count])){
    tabledone = @"Yes";
    }

tableView.backgroundColor=[UIColor clearColor];
tableView.opaque=NO;
tableView.backgroundView=nil;

NSString *a = [arrAllheight objectAtIndex:[indexPath row]];
// NSLog(@"allheight=%d",allheight);

allheight +=thisheight; 
thisheight =[a intValue];   


if(![tabledone isEqualToString:@"Yes"])
if([type isEqualToString:@"YN"]){

    DCRoundSwitch *ynSwitch = [[DCRoundSwitch alloc] initWithFrame:CGRectMake(220,thisheight-40,80,27)] ;  

    ynSwitch.onText=@"Yes";
    ynSwitch.offText=@"No";
    [answers addObject:ynSwitch];
    [cell addSubview:ynSwitch];
    [ynSwitch setTag:[cell_id intValue]]; 
    [ynSwitch addTarget:self  action:@selector(setAnswersForRoundSwitches:) forControlEvents:UIControlEventValueChanged];

           NSLog(@"cell_id=%@", [dicAnswers objectForKey:[NSString stringWithFormat:@"", cell_id]]);

//    if[dicAnswers objectForKey:[NSString stringWithFormat:@"", cell_id]]){}
    i++;


}else if([type isEqualToString:@"freetext"]){

    //When the done button was clicked, remove the keybords from the screen
    [self makeTextField];

    [rtxtfield addTarget:self  action:@selector(setAnswersfortextFields:) forControlEvents:UIControlEventEditingDidEndOnExit];
    //    [rtxtfield value]; 



}else if([type isEqualToString:@"dropdown"]){

    picc = [picker_array objectForKey:[[NSString alloc]  initWithFormat:@"%d",cell_id]];

    //Choose an array for this textField
    // [self getPickerArray];
    [self makeTextField];
    //[rtxtfield addTarget:self  action:@selector(setAnswersfortextFields:) forControlEvents:UIControlEventEditingDidEndOnExit];  

    //When the done button was clicked, remove the keybords from the screen
    [rtxtfield addTarget:self action:@selector(textFieldReturn:) forControlEvents:UIControlEventEditingDidEndOnExit];
    //Get the tag for picker
    [rtxtfield addTarget:self action:@selector(getTag:) forControlEvents:UIControlEventTouchDown];     
    //Display picker
    [rtxtfield addTarget:self action:@selector(acsheet:) forControlEvents:UIControlEventTouchDown];     
    //set Tag for the textField
    [rtxtfield setTag:[cell_id intValue]];
       NSLog(@"rtxtfield tag=%d",rtxtfield.tag);

}


if([type isEqualToString:@"devider"]){   
[self caliculateHeightofCell];
}else{
[self caliculateHeightofCell];
}  



return cell;

}

get tag name when user finished editing:

-(void)getTag:(UITextField*)txtf{
NSLog(@"-------------getTag-------------");
whichTextTag = txtf.tag;
picc = [picker_array objectForKey:[[NSString alloc]  initWithFormat:@"%d",whichTextTag]];
[self getPickerArray];
}

lifecycle:

- (void)viewDidLoad
{
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"main_bg.png"]];
 //   [super viewDidLoad];

    dicAnswers = [NSMutableDictionary dictionary];
[self getClaimQuestions];
[self  getSchemeLimitThreshold];
[self getShchemeLimit];

    tabledone=@"";
[self getQuestionsAY];

 //   [self getQuestionsH]; 
[self getCountries];

//  [self getQuestions];
[self getITClass];
self->table.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self->table.separatorColor = [UIColor lightGrayColor];


[self placeNextButton];
   // tabledone =@"Yes";

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:12:44+00:00Added an answer on May 29, 2026 at 8:12 pm

    Are you using interface builder? Then check if you have not connected the tableview to the controller twice in IB – once as the view outlet and again as table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, I know this question is easy, but I don't know how to get
Hi Sorry for posting a big dump of code but I'm very new at
First up, sorry for the mega-posting of code but... I have the following DB
Sorry for this simple question, but I can't solve it... There is an example:
Sorry but I am not sure how to ask this question but I am
Sorry if this question seems stupid, but it's stumped me for a couple days,
Sorry if this is a stupid question, but is there an easy way to
Sorry for posting this but !function is not google-able and I did not find
--EDIT -- So sorry that I confused people, I just quickly typed this code
Here is what I have so far: http://jsfiddle.net/6j4cT/3/ Sorry for not pasting the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.