Beispiel #1
0
def pickerView_viewForRow_forComponent_reusingView_(self, cmd, picker_view,
                                                    row, component, view_ptr):
    idx = row % len(assets)
    if (idx, component) in view_of_row:  # add V0.1
        #print('reuse',component,row,idx)					# test						# add V0.1
        view = view_of_row[(idx, component)]  # reuse view			# add V0.1
        view.setHidden_(False)  # not sure needed	# add V0.1
        return view.ptr  # add V0.1
    UIPickerView = ObjCInstance(picker_view)
    if view_ptr == None:
        #print(row, component)
        view = ObjCClass('UILabel').alloc().init()
        #view.text = str(row)+','+str(component)			# test only			# add V0.1
        iv = ui.ImageView()
        iv.frame = (0, 0, UIPickerView.myRowWidth, UIPickerView.myRowHeight)
        iv.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        if type(assets) is str:
            iv.image = emoji_to_image(assets[idx], w=iv.width, h=iv.height)
        else:
            iv.image = assets[idx].get_ui_image(size=(iv.width, iv.height))
        view.addSubview_(ObjCInstance(iv))
        view_of_row[(idx, component)] = view  # add V0.1
    else:
        view = ObjCInstance(view_ptr)
    return view.ptr
def pickerView_viewForRow_forComponent_reusingView_(self, cmd, picker_view, row, component,view_ptr):
    UIPickerView = ObjCInstance(picker_view)
    if view_ptr == None:
      view = ObjCClass('UILabel').alloc().init()
      #view.setText_('test')
      iv = ui.ImageView()
      iv.frame = (0,0, UIPickerView.myRowWidth, UIPickerView.myRowHeight)
      iv.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
      iv.image = UIPickerView.assets[row].get_ui_image(size=(iv.width,iv.height))
      view.addSubview_(ObjCInstance(iv))
    else:
      view = ObjCInstance(view_ptr)
    return view.ptr