Search Unity

"Sticky" scrolling in UITableView and UIScrollView when interfacing Unity and Obj-C

Discussion in 'iOS and tvOS' started by robinamasio, Nov 30, 2011.

  1. robinamasio

    robinamasio

    Joined:
    Dec 3, 2009
    Posts:
    5
    Hi all,

    This is a bizarre and very frustrating problem. I'm using Unity 3.4.2f2 and Xcode 4.0.2.

    I have built a Cocoa Touch UI for a Unity iOS application, which I'm invoking using Matt Mechtley's method (polling PlayerPrefs for special values, and hiding the EAGLView in order to display Cocoa Touch UIView's.)

    The Cocoa Touch UI I've built is your standard UINavigationController-with-mutiple-UITableViewControllers deal, like when you're searching through your music. And it works fine when I build it in its own Xcode project, without Unity.

    However, when I integrate it into my Unity project, the UITableViews (and UIScrollViews, which I'm using in some places) will intermittently "stick" while scrolling. They won't stop scrolling completely, and they will still respond to *some* touch input (I can move the scroll up and down). But when it's in this state, it doesn't do "inertial" scrolling (the scrolling doesn't continue after you raise your finger from the screen) and a UITableView will not let me select a cell.

    This state sometimes lasts for only a second or two, and sometimes indefinitely.

    I had figured that the Unity content running in the background was just taking up too much processing power, so I exposed the "UnityPause()" function in the boilerplate AppController.mm class so that I can pause Unity when I need to display a Cocoa Touch UI and restart it again when needed. Unfortunately, this doesn't solve the problem.

    Has anyone seen a problem like this? Any ideas at all about what could be causing it or how to fix it?

    Many thanks in advance,

    -r
     
  2. easinewe

    easinewe

    Joined:
    Jun 7, 2010
    Posts:
    5
    We are experiencing a similar issue. The scrolling seems to get stuck at random times and we don't get any errors in our console. Wonder if you ever found a solution for this.
     
  3. robinamasio

    robinamasio

    Joined:
    Dec 3, 2009
    Posts:
    5
    Hello folks,

    We finally found a fix for this, entirely by accident, and it's mind-bogglingly silly. Here's hoping it will work for you as well.

    In the Unity-generated AppController.mm file, there is a constant called USE_DISPLAY_LINK_IF_AVAILABLE. Set this constant to 0:

    #define USE_DISPLAY_LINK_IF_AVAILABLE 0

    For some explanation as to what's going on here (hardly thorough, but better than nothing), look here:

    http://unity3d.com/support/documentation/Manual/iphone-Optimizing-MainLoop.html

    Thanks very much all!

    -r
     
  4. alvaroull

    alvaroull

    Joined:
    May 8, 2012
    Posts:
    2
    Hi, do you have a demo for the uitableview integration?, I'm very interested in this.
     
  5. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    i had something similar and could solve it by experimenting with

    These values.

    #define USE_DISPLAY_LINK_IF_AVAILABLE 1


    //#define FALLBACK_LOOP_TYPE NSTIMER_BASED_LOOP
    #define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP
    //#define FALLBACK_LOOP_TYPE EVENT_PUMP_BASED_LOOP


    I don´t have the project here and cannot remember which combination it was. I think i used define FALLBACK_LOOP_TYPE NSTIMER_BASED_LOOP and maybe USE_DISPLAY_LINK_IF_AVAILABLE 0