2011-12-14 8 views
0

夜間モードのビューを持つリーダーアプリケーションがあります。つまり、ユーザーがUISwitchボタンをタップすると、tableview、text label.text、およびラベルの背景がわかりますすべてのものが完璧に動作しますが、バグは私がUIスイッチをタップするとバックグラウンドが最初に変わらず、テーブルビューをスクロールしてこのエフェクトを有効にする必要があります。背景に黒い画像がありますテーブルビューの.myコードはUITableViewにアクションを実装するときに不明なバグ

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

     static NSString *CellIdentifier = @"Cell"; 

     readCell *cell = (readCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"readCell" owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 

      if (imagedarkbackground.hidden == NO) 
      { 

        cell.chapterAndVerse.backgroundColor= [UIColor clearColor]; 
        cell.chapterAndVerse.textColor = [UIColor whiteColor]; 
        cell.textLabel.textColor = [UIColor whiteColor]; 
        cell.textLabel.highlightedTextColor = [UIColor whiteColor]; 
        //cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:16]; 
      } 
      else if (imagedarkbackground.hidden == YES) 
      { 
        cell.chapterAndVerse.backgroundColor= [UIColor whiteColor]; 
        cell.chapterAndVerse.textColor = [UIColor brownColor]; 
        cell.textLabel.textColor = [UIColor darkGrayColor]; 
        cell.textLabel.highlightedTextColor = [UIColor darkGrayColor]; 
      } 

です。私のコードに問題はありますか?なぜローライト効果を変更するにはどうすればいいですか? 。ありがとうございます。

+0

をリロード(セル== nilの)場合(imagedarkbackground.hidden == NO)は、前の条件内であれば、あなたのですか? – saadnib

+0

@saadnibは答えを得ました。単にテーブルrelodedtaをUISwitchのクリックカチオンに入れました。 – ICoder

答えて

1

cellForRowAtIndexPathは、セルをスクロールして表示する場合にのみ呼び出されます。表示されているセルをtableViewリロードまたはリフレッシュする必要があります。詳細は、ドキュメントを参照してください。

+0

、私は答えを得ました。私は何をしたのですか?ボタンをクリックしてテーブルを再読み込みします。 – ICoder

+0

@ICoder答えを受け入れることを忘れないでくださいあなたを助けました。 –

0

私は単にこの

-(IBAction)switchingbtn:(id)sender { 

    if(switchControll.on){ 

     [switchControll setOn:YES animated:YES]; 

     imagedarkbackground.hidden = NO; 
     [table reloadData]; 

    }else{ 
     [switchControll setOn:NO animated:YES]; 

     imagedarkbackground.hidden = YES; 
     [table reloadData]; 
    } 

} 

感謝のようなuiswithcontrollerのボタンクリックで[table reloadData];を入れて私の答え を得ました。スイッチボタンのボタンクリックイベントで

1

は、テーブルビュー

- (IBAction)switchButtonClicked { 
// Some code 
[yourTableView reloadData]; 
} 
関連する問題