• @mikael Thanks for the pull to refresh example. I really appreciate the help. I had a couple issues. The biggest issue was only being able to refresh once after the view is loaded. The second Issue was when pulled too far down, the refresh function was called multiple times. I think I solved these issues. I attached the solution I came up with below.

    import ui, sound class scrollViewDelegate: maxPull = -100 def __init__(self): self.refresh = False def scrollview_did_scroll(self, scrollview): x, y = scrollview.content_offset if y <= 0: delta = max(y, self.maxPull) / self.maxPull if (y <= self.maxPull and not scrollview.tracking and scrollview.decelerating and not self.refresh): scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.50, 0.50, 0.50, delta self.contentRefresh() elif (y <= self.maxPull - 10 and scrollview.tracking and not scrollview.decelerating and not self.refresh): scrollview['refresh_bg']['refresh_label'].text = 'Release to refresh' scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.50, 0.50, 0.50, delta elif (y >= self.maxPull - 10 and scrollview.tracking and not scrollview.decelerating and not self.refresh): scrollview['refresh_bg']['refresh_label'].text = 'Pull to refresh' scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.60, 0.60, 0.60, delta def contentRefresh(self): self.refresh = True sound.play_effect('ui:click3') #print('refreshing') ui.delay(self.contentDidRefresh, 0) def contentDidRefresh(self): self.__init__() w, h = ui.get_screen_size() sv = ui.ScrollView() sv.name = 'Scrollview' sv.always_bounce_horizontal = False sv.always_bounce_vertical = True sv.directional_lock_enabled = True sv.scroll_indicator_insets = (10, 0, 10, 0) sv.bounces = True sv.paging_enabled = False sv.indicator_style = 'black' sv.scroll_enabled = True sv.background_color = 1.0, 1.0, 1.0 sv.content_inset = (0, 0, 0, 0) sv.content_size = (w - 10, h*2) sv.delegate = scrollViewDelegate() rb = ui.View() rb.name = 'refresh_bg' rb.alpha = 1.0 rb.background_color = 0.90, 0.90, 0.90 rl = ui.Label() rl.name = 'refresh_label' rl.alpha = 1.0 rl.alignment = ui.ALIGN_CENTER #rl.background_color = 'white' rl.text = 'Pull to Refresh' rl.text_color = None rl.font = ('<system>', 14) rb.add_subview(rl) sv.frame = (0, 0, w, 0.5) rb.frame = (0, -600, sv.width, 600) rl.frame = (0, rb.height - 32, sv.width, 32) sv.add_subview(rb) sv.present('fullscreen')
  • Thanks all, as usual!

    The wait for the table view to become valid can be very short, as short as 0.01 seconds, apparently. Unfortunately there's no simple way to be notified when a UIView becomes visible (anyone have a generic notification-y way of doing that?), and even then I don't know that just being visible for a table view is the same as it having valid rows/indices.

    Also, to scroll to a specific row turns out to be very easy, once you have a table view with valid indexes displayed:

    UITableViewScrollPositionMiddle = 2 tvobjc = self.tableview.objc_instance NSIndexPath = objc_util.ObjCClass("NSIndexPath") nsindex = NSIndexPath.indexPathForRow_inSection_(index,0) tvobjc.scrollToRowAtIndexPath_atScrollPosition_animated_(nsindex, UITableViewScrollPositionMiddle, True)

    Works great, set that last parameter to False to scroll without animation.

  • ...couldn't resist.
    MiniPhotoView

  • Fair enough. But I think it's something to watch out while you are playing in your box of goodies. Is a great effect. Could be used in so many ways. I could make a poker machine in about 10mins with that sort of effect. I could also make ui.Views appear and disappear in a variety of ways with that functionality. But, I am sure you are right, doing it with ui.delay would not cut it.

  • Oh another benefit , I guess I get off the main thread.

Internal error.

Oops! Looks like something went wrong!