Search code examples
iosobjective-cuitableviewdevelopment-environmentsetbackground

How to set tableview background color of parent view controller from inherit child view controller


How it possible to change color of overlapp tableview in child veiw controller.Here is the code but not working.......

  @interface ChatViewController : SOMessagingViewController

     -(void)viewWillAppear:(BOOL)animated{
          SOMessagingViewController *obj=[[SOMessagingViewController alloc]init];
          obj.tableView.backgroundColor =[UIColor redColor];

         }

Solution

  • You do not need to create a new instance of SOMessagingViewController.

    Simply change your code to:

    - (void)viewWillAppear:(BOOL)animated {
        self.tableView.backgroundColor = [UIColor redColor];
    }
    

    Since your ChatViewController class extends SOMessagingViewController, you have access to all of the public members directly.