Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UISplitViewController's MasterViewController's tableView view background color

alter3choalter3cho Posts: 6New Users Noob
I have a a SplitViewController and i change the tableView's ( of the MasterView) background color to clear color when the view appears, and change it back to white in the viewWillDisappear method in the MasterView.

But, this change does not take place until the next time the tableView appears. This makes the tableView look jarring (you can see the black background), during device rotation.

To recreate what i'm talking about, You can place the following in a new UISplitViewController application:
- (void)viewDidAppear:(BOOL)animated
{
    self.tableView.backgroundColor = [UIColor clearColor];  
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.tableView.backgroundColor = [UIColor whiteColor]; //the color changes, only the next time the tableView appears.
}

Can some one please explain why the code in the viewWillDisappear method does not reflect immediately?

Replies

  • dev666999dev666999 Posts: 3,621New Users @ @ @ @ @
    This makes the tableView look jarring (you can see the black background), during device rotation.

    The simplest solution to your problem is to change the UIColor of that black background to whiteColor. Then you won't see that jarring transition. I assume it's another view that is temporarily visible during the transition.
  • alter3choalter3cho Posts: 6New Users Noob
    edited August 2014
    I DID change the background color to white, with the bock:
    - (void)viewWillDisappear:(BOOL)animated
    {
         self.tableView.backgroundColor = [UIColor whiteColor];
    }
    
    The problem is, the change is not reflected immediately. You can see the change, only the next time tableView appears.
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,690Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    So many questions...

    1. What is the point of changing the color when the view is off screen? It is off screen... who cares what color it is?

    2. Should you be using viewWillAppear instead of viewDidAppear? I ran a quick test as you suggested, and I found the clear color change to be far more jarring than the black you are talking about.

    3. The black is coming from the app's window. You can verify this yourself like so:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [[self window] setBackgroundColor:[UIColor redColor]];
    ...
    

    I tried it a few times in the simulator with slow-speed animations, and I can't really explain why the color change is not taking effect. I'm not entirely sure what it is doing. It's like a color moves in from the side, but the table view cell dividers are still full width. I'll make a guess that there is some kind of conflict with the rotation animation, but I couldn't tell you what to do about it, and the need seems kind of pointless to me.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | SlickShopper 2 | Leave a PayPal donation
  • dev666999dev666999 Posts: 3,621New Users @ @ @ @ @
    3. The black is coming from the app's window.

    Exactly, so... like I suggested, the OP could change that to white so that there is no blink.

  • alter3choalter3cho Posts: 6New Users Noob
    edited August 2014
    I want the tableView background of the MasterViewController to be of clear color, but since making it clear makes black background become visible during the rotation animation, i try to set it to white color in the 'viewWillDisappear:' method.

    if i set clear color in 'viewWillAppear', then the black background shows through during when screen rotated to portrait, too.

    I am puzzled why the changes made in the 'viewWillAppear:' don't show immediately.
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,690Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    The clear color has nothing to do with what you are seeing. Seriously, remove your clearColor call, change the window background to red like I showed, and then watch. You'll still see the red.

    BTW, you should always call super from these methods:
    - (void)viewDidAppear:(BOOL)animated
    {
       [super viewDidAppear:animated];
    
       self.tableView.backgroundColor = [UIColor clearColor];  
    }
    
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | SlickShopper 2 | Leave a PayPal donation
  • alter3choalter3cho Posts: 6New Users Noob
    dev666999 wrote: »
    3. The black is coming from the app's window.

    Exactly, so... like I suggested, the OP could change that to white so that there is no blink.
    Sorry, i din't see your comment. That's a wonderful idea, but it only seems to make it less jarring. I could try matching the colors. Need to experiment with that idea.
  • dev666999dev666999 Posts: 3,621New Users @ @ @ @ @
    I don't know if this answers your question...

    I would set the Window's background color in the AppDelegate. So that it's white when the app opens, thereby avoiding any lag or delay.
  • alter3choalter3cho Posts: 6New Users Noob
    BrianSlick wrote: »
    The clear color has nothing to do with what you are seeing. Seriously, remove your clearColor call, change the window background to red like I showed, and then watch. You'll still see the red.

    BTW, you should always call super from these methods:
    - (void)viewDidAppear:(BOOL)animated
    {
       [super viewDidAppear:animated];
    
       self.tableView.backgroundColor = [UIColor clearColor];  
    }
    

    Yes, i understand that it is the color of window's background, but it is still puzzling, why the code i set in the viewWillDisappear does not take effect until after the rotation animation has finished.
    dev666999 wrote: »
    I don't know if this answers your question...

    I would set the Window's background color in the AppDelegate. So that it's white when the app opens, thereby avoiding any lag or delay.
    Yup, your solution is the closest to making it less jarring.
Sign In or Register to comment.