kristopherjohnson / tilessample

Core Animation example code that emulates the iPhone home screen re-organization UI.
http://undefinedvalue.com/2010/02/05/iphone-sample-code-tiles-arrangement
33 stars 8 forks source link

Problem with navigation controller #3

Open zeeshankhan opened 11 years ago

zeeshankhan commented 11 years ago

Hi,

While adding tile view controller into a navigation controller with navigation bar visible, tile frame gets misplaced by 44 pixels. It also affects tapping on a tile.

I have tried with placing a seperate UIView on top of view controller's view and then adding all the tiles into that view, but still it misplaces.

I am not understanding the behaviour, please help.

Many Thanks.

kristopherjohnson commented 11 years ago

I haven't tried putting TilesViewController into a navigation controller (or anything else).

I don't know what's going on and haven't tried debugging this, but I have noticed that -[TilesViewController createTiles] doesn't take into account the bounds of the enclosing view when calculating frames for the tiles. If the enclosing view's origin is not (0, 0), then it won't be putting them in the right place. You might try offsetting each tileFrame by the enclosing view's origin.x and origin.y.

zeeshankhan commented 11 years ago

Thanks for the reply.

Only change I did in the project to add a navigation stack in App Delegate file:

UINavigationController *navCont = [[UINavigationController alloc] initWithRootViewController:viewController]; [window setRootViewController:navCont]; // [window addSubview:viewController.view]; [window makeKeyAndVisible];

I have tried multiple option along with setting offset through CGRectOffset to fix the issue but it didn't work for me.