1
votes

I came across this while debugging why my scrollView wouldn't scroll. For context, the structure of my layout is:

-ScrollView
  - View
     - labels, images, buttons

Updating the scrollView.contentSize to match the (sub)view wasn't working, so I put in some debug statements. Turns out the view's frame is sized 0, 0 when i NSLog its description, but if i run the debugger's recursiveDescription, it shows different.

Any idea why, and could that be affecting why my scrolling isn't working?

From NSLog(@"%@", [self.view description])

2012-11-15 17:16:46.707 Comparo[65731:11303] starting: <UIView: 0x7144590; frame = (0 0; 0 0); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

2012-11-15 17:16:46.708 Comparo[65731:11303] 1: <UIView: 0x7144590; frame = (0 0; 0 0); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

2012-11-15 17:16:46.771 Comparo[65731:11303] 2: <UIView: 0x7144590; frame = (0 0; 0 0); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

2012-11-15 17:16:46.771 Comparo[65731:11303] 3: <UIView: 0x7144590; frame = (0 0; 0 0); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

2012-11-15 17:16:46.772 Comparo[65731:11303] 4: <UIView: 0x7144590; frame = (0 0; 0 0); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

Debugger output for: (lldb) po [[UIApp keyWindow] recursiveDescription]

...

| | | | <UIScrollView: 0x71494d0; frame = (0 0; 320 504); clipsToBounds = YES; autoresize = TM+BM; gestureRecognizers = <NSArray: 0x75d3bb0>; layer = <CALayer: 0x71f9ed0>; contentOffset: {0, 0}>

| | | | | <UIView: 0x7144590; frame = (0 0; 320 523); autoresize = TM+BM; layer = <CALayer: 0x714b4f0>>

Thanks.

1
In what methods are your NSLog statements?rob mayoff
the numbers are just for my reference but they're strewn throughout starting in viewdidload, throughout my setup function at different points and at the very end after the text labels etc are updatedmyclues
Your view frames won't necessarily be set correctly when you receive viewDidLoad. Check out this answer.rob mayoff
yeah i don't expect them to be correct right at the start of viewdidload but i guess there's now ay to guarantee when it will actually complete until the end of that sequence. thanks!myclues

1 Answers

1
votes

Thanks Rob!

You were right about it being a timing issue and there's no way to guarantee that frames will be finalized in viewDidLoad (where I had my NSLog statements). I moved the statements to viewDidAppear:, which is where the user will first be able to interact with them and scroll anyway, and the numbers match up now.

Bonus: solved my scrolling issue too.