def set_page(self, page_number):
if page_number < self.pageControl.numberOfPages() and page_number > -1:
x = page_number * self.scrollView.width
self.scrollView.content_offset = (x, -20) # ⥢⬅ here
raise ValueError("Invalid Page Number. page_number is zero indexing.")
Your favorit override..
added an instance variable to it though..
def __init__(self, **kwargs):
self.titleBarAdjustment=0 # ⥢⬅ here
#with this guy..
def present(self, **kwargs): # evaluate input before presenting
self.scrollView.y=20 #if hide_title_bar then adjust scrollView
super(PageControl, self).present(**kwargs) # Continue..
the second option needs to know if the bar is present otherwise it just has a revers effect to original image issue.. (jumps up)
im still looking for a beter solution for this. the objc methods were not working last night and im sure it was writers error. but im the mean time at least two of these will hold by maybe?
as for your other issues..
Depending on your phone and tabelets they could be explained.
i suspect that it has todo with Retina scaling and resolution. i have an iPhone 6s and iPad Air 2 and they both have a 2x1 Retina Display so i dont get this issue but id imagine if u has a 2x1 phone and 3x1 ipad it would creat this. all you really need to do if thats the case is check device at runtime and setup Layout accordingly. ui/scene, atleast for 2x1, should auto compensate for this but pil doesnt. just for future info lol.. but by using ui.from_data(data, scale) is where u set scaling for retina convertion. this could help if your dispay happends to be a factor. if i find anything ill let you know!
@mikael I'm not very creative with these things - do you have some example code based on objc_util that I could translate to Rubicon?
In general the syntax for classes looks like this:
from rubicon.objc import NSInteger, NSObject, ObjCProtocol, objc_method
WhateverDelegate = ObjCProtocol("WhateverDelegate")
class MyCustomDelegate(NSObject, protocols=[WhateverDelegate]):
# the protocols=[...] part is optional of course, if you don't need to implement any protocol
def someThing_didAThingWithCount_(self, something, count: NSInteger) -> None:
something.delegate = MyCustomDelegate.new()
The Python 3 type annotation syntax is used to set each method's return and argument types. You use regular ctypes type objects for the types, and Rubicon predefines some common typedefs like NSInteger. Anything you don't annotate is assumed to be an Objective-C object (ObjCInstance).
In answer to my own question at the end there: that "locations" parameter is not a "const float *", it is actually "const CGFloat *" which can be 32 or 64 bits depending on platform architecture, and therefore a C float is not necessarily compatible...so I needed to explicitly use the CGFloat datatype:
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.
@JonB got it...thanks for the reply! I figured something like that was the reason...that these were not functions in any sense which could be "called". I can use one of a few ways I've found to do what I need in the cases I've seen.
You can present your view, then traverse the heirarchy to see all of the UIViews. Tapping an item highlights it onscreen.
Also, any action/targets are shown as little chain icons, which you can tap and it prints to the console the details on the target, selector, event codes, etc. Tapping the info button shows all of the objc properties, which is also navigatable.