objc_hacks icon indicating copy to clipboard operation
objc_hacks copied to clipboard

tableview_rowheight does not work on all devices

Open jsbain opened this issue 8 years ago • 14 comments

@Phuket2 can you try running tableview_rowheight_tests.py (in same folder as the swizzle and tableview_rowheight.py), and paste the output here?

jsbain avatar May 12 '16 04:05 jsbain

As requested

#########
Pythonista3/Documents/MyProjects/jonb/obj_hacks/Tests.py
Pythonista3/Documents/MyProjects/jonb/obj_hacks/tableview_rowheight.py
Pythonista3/Documents/MyProjects/jonb/obj_hacks/swizzle.py
Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/ui.py
Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/objc_util.py
<SUITableView_PY3: 0x138e02400; baseClass = UITableView; frame = (0 0; 200 576); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x13a24f2e0>; layer = <CALayer: 0x13d9a4c50>; contentOffset: {0, 0}; contentSize: {0, 0}>
<ui.ListDataSource object at 0x13958b318>
<objc_util.ObjCInstanceMethod object at 0x1393d7f88>
-1.0
-1.0
0.0
no delegate yet: should return -1
-1.0
no delegate yet: should return 24
24.0
tableview_height_for_section_row called: <_ui.TableView object at 0x139483558> 0 0
10.0
make sure we can still get # rows and the actual cells
100
<SUITableViewCell_PY3: 0x13e4df8e0; baseClass = UITableViewCell; frame = (0 0; 320 44); text = '0'; layer = <CALayer: 0x13dd6e3f0>>

Phuket2 avatar May 12 '16 07:05 Phuket2

hmm. evrything appears fine... the tableview was successfully swizzled and is giving valid results. Can you repeat this with a t.present('sheet') at the end?

jsbain avatar May 12 '16 07:05 jsbain

also, try that same line where it says "no delegate yet"-- you should get a valid tableview at least

jsbain avatar May 12 '16 07:05 jsbain

With just the t.present('sheet') at the end of the test, py3 crashes. Even if I don't touch the view. Takes a few seconds, but it crashes. I will try and get it set up on my iPhone 6s. Will take a little while as I am quite behind on my iPhone. Will post back here as soon as I try it

Phuket2 avatar May 12 '16 07:05 Phuket2

Ok, wow...got it to my iPhone 6s. Is a new install of py3 beta, the latest as per TestFlight. Exactly the same thing. I tried the present in both locations. Same results. No text. The lines are not variable heights, but since the test file they are not as high as running the example. The artifact still shows up on the first line with presenting with the new test file, on both devices.

Phuket2 avatar May 12 '16 08:05 Phuket2

Just to be 1000% sure, I also renamed my startup file and restarted to make sure nothing crazy was happening with that. Did not change anything

Phuket2 avatar May 12 '16 08:05 Phuket2

ok, i had a thought, trying to add on main thread in two places. two files updated.
try the new version. also, i try loading the tableview inside another view

jsbain avatar May 12 '16 23:05 jsbain

Sorry, I didn't work. Exactly same look as before. No text in the rows and that pesky artifact is still on the first line :( Here is the print from the latest test file

######### Pythonista3/Documents/MyProjects/jonb/obj_hacks/tableview_rowheight_tests.py Pythonista3/Documents/MyProjects/jonb/obj_hacks/tableview_rowheight.py Pythonista3/Documents/MyProjects/jonb/obj_hacks/swizzle.py Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/ui.py Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/objc_util.py <SUITableView_PY3: 0x143a22c00; baseClass = UITableView; frame = (0 0; 200 320); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x142c9b980>; layer = <CALayer: 0x1441dba00>; contentOffset: {0, 0}; contentSize: {0, 0}> <ui.ListDataSource object at 0x1433416d8> <objc_util.ObjCInstanceMethod object at 0x1431f9f38> -1.0 -1.0 no delegate yet: should return -1 -1.0 no delegate yet: should return 24 24.0 10.0 make sure we can still get # rows and the actual cells 100 <SUITableViewCell_PY3: 0x145866700; baseClass = UITableViewCell; frame = (0 0; 320 44); text = '0'; layer = <CALayer: 0x143213320>>

Phuket2 avatar May 13 '16 08:05 Phuket2

@jonb, if this is becoming a pain for you. It's ok we can just leave it. I am more than ok to test, but don't want to take up your time. So if you want to stop, I understand.

Phuket2 avatar May 13 '16 08:05 Phuket2

Oh, I played around with font_size, font_color, bg_color in case it was magically rendering white text, But that does not seem to be the issue

Phuket2 avatar May 13 '16 08:05 Phuket2

on 64 bit, the encoding for the delegate was changed from float to double. i was hardcoding a float new one will work for sure this time! tableview_rowheight.py was updated

jsbain avatar May 13 '16 15:05 jsbain

Not quite. I think this is just a typo. But sorry I don't know how to fix it

swizzle.swizzle(ObjCClass(t_o._get_objc_classname()),
                                ('tableView:heightForRowAtIndexPath:'),
                                tableView_heightForRowAtIndexPath_,CGFloat+b'@:@@')

The above line is causing a unsupported operands type(s) for ....

Phuket2 avatar May 13 '16 15:05 Phuket2

ack, sorry pushed wrong version. fixed now. restart pythonista first

jsbain avatar May 13 '16 15:05 jsbain

Yeah!!!! Success But now I start trying to use it 😱

Phuket2 avatar May 13 '16 17:05 Phuket2