• shinyformica

    @mikael it works...it isn't feature-complete, and I was unable to figure out how to consistently get the proper animation of items when they are moved to a new location (it doesn't always animate the properties of the moved cell in the right way, or the cell in the new location is displayed before the move animation happens).

    Let me try to extricate the code which is unrelated to the implementation of the UICollectionView from the custom code for my specific purposes. Maybe someone can figure out why my end-move animation is wonky.

    posted in Pythonista read more
  • shinyformica

    @mikael sweet! Didn't realize the magnificent Gestures module already had exactly what I needed.

    posted in Pythonista read more
  • shinyformica

    Presenting a view with style = "full_screen" and hide_title_bar = True will enable that special two-finger-swipe "emergency exit" gesture, which will force the view to close.

    Is there a way to disable that gesture? For my script, I actually may have situations where two fingers will swipe down fast enough to cause that emergency exit to close the presented view. It would be a rare event, thankfully, but it is possible, so I'd like to turn it off altogether.

    posted in Pythonista read more
  • shinyformica

    @dgelessus thanks so much for the deep knowledge!

    So now this whole thing is working! As it turns out a lot of this was a red herring.

    In summary:

    • It is perfectly legal to use the python string value "UICollectionElementKindSectionHeader" directly in the registerClass_forSupplementaryViewOfKind_withReuseIdentifier_() objc method, since it is converted to an NSString object implicitly.
    • The value returned by ctypes.c_void_p.in_dll(objc_util.c, "UICollectionElementKindSectionHeader") works as well, I assume since that c_void_p ends up being interpreted as an NSString object.
    • Of course, objc_util.ObjCInstance(ctypes.c_void_p.in_dll(objc_util.c, "UICollectionElementKindSectionHeader")) works, and is probably "safest" since you get the actual value without having to guess, and it is turned into a correct type.
    • You cannot directly use the _FuncPtr value returned by objc_util.c.UICollectionElementKindSectionHeader but there might be some way to convert that _FuncPtr value (just doing a ctypes.cast(funcptr, ctypes.c_void_p) does not work).

    Now, the reason the whole thing was a red herring: collection views won't even bother to call the collectionView_viewForSupplementaryElementOfKind_atIndexPath_() method unless the flow layout object being used to layout the items has had its headerReferenceSize property set to something other than the default CGSize(0,0)...so even when I was successfully registering the class with the method to create section headers, it wasn't being called.

    posted in Pythonista read more
  • shinyformica

    @mikael thank you, checking out that thread now...and yes I was secretly hoping one of the objc gurus on here would know what I was missing. I think what's happening here is that Apple is actually using the address of the NSString* and not any actual string value.

    @cvp are you saying that I can just directly use the value I pull from objc_util.c.UI CollectionElementKindSectionHeader in the objc method call? With no translation?

    posted in Pythonista read more
  • shinyformica

    @mikael indeed, that was the first thing I tried...unfortunately it didn't work. I actually think I am missing something obvious here. I can find where it is defined in objective-c, but the definition contains no actual string value, and I can find no place where a string value is specified:

    NSString *const UI Collection ElementKind SectionHeader;

    (as before, remove the spaces in the spammy name of the constant).

    posted in Pythonista read more
  • shinyformica

    It was! It was the actual name of the constant, which is just nuts.

    posted in Pythonista read more
  • shinyformica

    Little update...in desperation, I started scrounging around in objc_util.c for the name...and it looks like there actually are both:

    UI CollectionElementKind SectionHeader
    and
    UI CollectionElementKind SectionFooter

    symbols defined in there...though they show up as ctypes._FuncPtr objects...attempting to call them without arguments, or with None as the argument, crashes pythonista.

    So...anything I can do with those?

    posted in Pythonista read more
  • shinyformica

    Hey all...trying desperately to get this topic through the aggressive spam filter...crazily it seems like the name of the uikit constant I'm asking about is itself being flagged as spam.

    Anyway...I'm putting spaces in between each word of the name just to fool the filter:

    UI Collection Element Kind Section Header

    Trying to find the actual string value of that constant...my usual methods to find a value via google, in both objective-c and swift docs, etc. have all failed. You can see the definition of the constant by googling the name.

    Anyone have an idea how to pull the value? I need it to finish my pythonista'd wrapper of a collection view.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!