Yeah, that's exactly the error I was getting. Got it when trying to reuse a popover view as well.
The result I have by creating my own title bar is actually better for my purposes, so I'll stick with it.
Interesting to know about removing the view controller to disconnect the closed view from the animation state of the presenting controller.
There was an additional crashing issue: another version of the same problem when an object has gone out of scope in the python context when it is accessed in the objc context.
I need to re-inforce the understanding that just because a python object like a ui.View is technically placed in a view hierarchy, or otherwise connected to the objc world, the underlying objc instance of a UIView is not in any way holding a strong reference to that python object, and I think vice-versa.
So creating a local ui.View instance inside a method, and then adding that view to a purely objc view hierarchy, will not preserve the python object after it goes out of scope. So a later attempt to access the python object will segfault.
@cvp yes, that line isn't needed, I just copy-pasta'd this from a chunk of larger code...looks like I forgot to define "pos" too, which is a little complicated: it isn't simply a point in the parent coordinate system. It's a point in reference to the top-left corner of the top view in the view hierarchy which is presenting it.
I asked about getting that location a while ago, and got some good replies, so the little utility function to get that point is:
def popoverPoint(pos, sourceView):
srcobjc = sourceView.objc_instance
topobjc = None
parent = srcobjc.superview()
while parent is not None:
topobjc = parent
parent = parent.superview()
p = srcobjc.convertPoint_toView_(objc_util.CGPoint(*pos), topobjc)
@Webmaster4o , lol does not surprise me. But let's face it a lot of little treasures in Pythonista.
I wish they could all be documented, but I understand why they are not. It would take a big chunk out of the development time. I can't remember how long I have had Pythonista now, but I am astounded how much it has evolved in that short time.