-1

I have an issue which probably is fairly easy if you're not as blind as me. I have a tableview with customs cells, which are taking information from a datasource. In this custom cell I have a button which changes the datasource for all the cells. Pushing the button in one cell should make all the other cells dark. The datasource is changed, however my problem is that the cells only updates when I drag the cells in the table view. The method when the button is pushed is placed in the tableview and ends with [tableview reloadData]; but it only updates when dragged.

Any help is appreciated

--Update-- The following shows the method called when the button is pushed. The switch case changes the datasource. The button.tag is used to see in which cell the button is pushed.

-(void)myPackageButtonPushed:(id)sender
{
   UIButton* myButton = (UIButton*)sender;
   NSLog(@"id %d",myButton.tag);
   int test=myButton.tag;
   for (int i=0; i<[packageList count]; i++) {
        TVPackage *tvpack=[packageList objectAtIndex:i];
        [tvpack setMyPackage:NO];
    }

    switch (test) {
        case 0:
            NSLog(@"0");
            [[packageList objectAtIndex:0] setMyPackage:YES];
              [[packageList objectAtIndex:1] setMyPackage:YES];

            break;
        case 1:
            NSLog(@"1");
            [[packageList objectAtIndex:0] setMyPackage:YES];
            [[packageList objectAtIndex:1] setMyPackage:YES];
            break;
        case 2:
            NSLog(@"2");
            [[packageList objectAtIndex:2] setMyPackage:YES];
            [[packageList objectAtIndex:3] setMyPackage:YES];
            break;
        case 3:
            NSLog(@"3");
            [[packageList objectAtIndex:2] setMyPackage:YES];
            [[packageList objectAtIndex:3] setMyPackage:YES];
            break;
        case 4:
            NSLog(@"4");
            [[packageList objectAtIndex:4] setMyPackage:YES];
            [[packageList objectAtIndex:5] setMyPackage:YES];
            break;
        case 5:
            NSLog(@"5");
            [[packageList objectAtIndex:4] setMyPackage:YES];
            [[packageList objectAtIndex:5] setMyPackage:YES];
            break;
        default:
            break;
    }

    [self.tableview performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
    }
oers
  • 18,436
  • 13
  • 66
  • 75
Bjarke
  • 1,283
  • 11
  • 36
  • 1
    Do confirm whether the tableview is really reloaded or not, by setting breakpoint in cellForRowAtIndexPath method.. – Ilanchezhian Aug 02 '11 at 12:49
  • The method cellForRowAtIndexPath is not called immediate when [reload data] is called. I have several nslogs in cellForRowAtIndexPath which are called when the tableview. is dragged – Bjarke Aug 02 '11 at 12:55
  • As per your comment, you have not reloaded the tableview with valid object. Show the code snippets here to get the better solution. – Ilanchezhian Aug 02 '11 at 12:59

1 Answers1

0

I did not have the link between the Interface Builder and classes correctly set up. IB was set to a UIViewController instead of my specific class. Thank you for the help and your time.

oers
  • 18,436
  • 13
  • 66
  • 75
Bjarke
  • 1,283
  • 11
  • 36