Hi, I’m sure I’ll kick myself with the answer to this, but I was to create a custom drawing in a custom cell (let’s say it’s a square with two rounded and two right-angle sides), but I don’t want it to interfere with UI allowing the user to tap to fire the SelectionChanged event.
I think the only way yo do this is using a canvas, but I can’t stop the canvas from accepting PointerUp/Down events.
Does anyone know how to do this?
Thanks in advance
Chris
I don’t remember the exact name but @Jeremie_L iOSDesignExtensions have a method that allows you to disable the selection in a table. I think it’s for the entire table though if I remember that well.
If you only need to disable one line of the table, I usually use another method of Jeremie’s iOSDesignExtensions, which sets the cell’s selected color to transparent.
Thanks Christoph. I think you might have misunderstood me? I want the table to perform as normal (as if the canvas didn’t exist), so when you tap on it, it you can push the screen as normal
Sorry, I indeed misunderstood. So you have some code in the PointerDown or PointerUp events of the canvas? If not, I don’t think it should interfere with the table’s SelectionChanged event.
Solution 1
You could also create the custom drawing in a method and assign the resulting picture to a MobileImageViewer.
Dim cell As MobileTableCellData
cell = table.CreateCustomCell(GetTypeInfo(theCustomCell))
theCustomCell(cell.Control).CreateCustomDrawing // <- this is a method in your custom cell
table.AddRow(0, cell)
The downside of drawing outside of the MobileCanvas is that you need to handle the screen’s scale factor on your own.
Solution 2 (untested)
Try disabling user interaction with the canvas with this code:
Declare Sub userInteractionEnabled Lib "UIKit" Selector "setUserInteractionEnabled:" _
(obj As ptr, value As Boolean)
userInteractionEnabled(theCanvas.handle, false)
Thanks very much Jeremie. TheMobileImageViewer was the only solution I could come up with but I just thought there must be an easier way.
I’ll try your userInteractionEnabled suggestion and let you know if it works.
Thanks again for taking the time.
Nice one Jeremie! You’re untested code worked a treat. I just can’t imagine how good your tested code is
Thanks again. It saved me a lot of bother
1 Like