2

I have successfully implemented a working UIScrollView layer on top of Cocos2d using this fantastic tutorial:

http://bitbattalion.com/2011/09/uikit-uiscrollview-and-cocos2d/

However, the scroll view sporadically becomes sluggish and choppy, including almost always upon loading the scene. When it happens, the scrolling and is no longer is able to be flicked up or down with any sort of variable velocity. It also loses all of it's bounce and just stay partially of screen until the next touch is registered.

The weird thing is though, that if I simply pull down my Notification Center, it fixes the scroll view every time. The scrolling all of a sudden becomes perfectly fluid and the edges bounce beautifully into place.

What is happening here?

Nick
  • 111
  • 2
  • 6
  • It seems like the view is essentially fixing itself when the app exits to the background and then becomes active again - so you'll likely experience the same behaviour if you open the multitasking bar or just exit and reopen the app. Are you doing anything with the view in your `applicationDidBecomeActive` or `applicationWillResignActive` methods, or via their respective notifications? The more code you post, the better chance the flaw in your code can be found. – Andrew R. Feb 02 '12 at 03:08
  • Have you read the tutorials' link to "fixing it for iOS 5"? http://stackoverflow.com/questions/4876488/animation-in-opengl-es-view-freezes-when-uiscrollview-is-dragged-on-iphone – CodeSmile Feb 02 '12 at 10:13

1 Answers1

2

Instruments may help to tackle the problem. Run using the CoreAnimation Tool so you can get a good handle on where you might be experiencing the drop in frame rate. You'll need to have your device connected to run the CoreAnimation tool.

This tutorial is also available at http://mobileoverlord.com/instruments-optimizing-core-animation/

Select Profile from the build scheme.

Profiling

Select the CoreAnimation Profiling Tool CoreAnimation Profiling Tool

When the tool is running scroll around in your scroll view and keep an eye on frame rate. 60 is great.

CoreAnimation Tool Running

If you need to dial in on it any more you can turn on Color Blended Layers from the Debug Options in the Instruments Panel View(Menu) -> Instruments

Without Color Blended Layers (Left)

enter image description hereenter image description here

With Color Blended Layers (Right)

The basic rule of thumb here is, the more red you see the less optimized the view is for the animation. Although, you don't want to remove all red either, %50 is about right.

MobileOverlord
  • 4,580
  • 3
  • 22
  • 30