Closed sxross closed 11 years ago
I think I was able to get this working:
(on iOS7, so there's that silly status bar)
Here's how I did it:
diff --git a/app/app_delegate.rb b/app/app_delegate.rb
index 36ec472..11d77f6 100644
--- a/app/app_delegate.rb
+++ b/app/app_delegate.rb
@@ -36,9 +36,15 @@ class TableViewController < UITableViewController
cell.attendees_label = subview(UILabel, :cell_attendees_label, :text => "attendees #{indexPath.row}")
end
end
- cell.contentView.apply_constraints
+
cell
end
+
+ def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
+ cell.restyle!
+ cell.apply_constraints
+ end
+
end
class CustomCell < UITableViewCell
Unfortunately, this requires a change to the delegate, not something I can inject automatically. But you win some you lose some. My thinking is that this could be integrated easily:
class TableViewController < UITableViewController
module Teacup::TableViewDelegate
# ...
end
Would define tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
. If you need to define that method yourself, you can call super
there.
class TableViewController < UITableViewController
module Teacup::TableViewDelegate
def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
super
# stuff
end
# ...
end
This is working in this branch: https://github.com/rubymotion/teacup/tree/tablecell
Thanks for tracking this down. I've been up to my eyes in a Rails project for one of my best clients and MotionModel is really getting a lot of uptake and hence feature requests, issues, etc. which take time. Maybe I can get back to my iOS app one day :)
Steve
On Jun 28, 2013, at 8:40 AM, "Colin T.A. Gray" notifications@github.com wrote:
I think I was able to get this working:
(on iOS7, so there's that silly status bar)
Here's how I did it:
diff --git a/app/app_delegate.rb b/app/app_delegate.rb index 36ec472..11d77f6 100644 --- a/app/app_delegate.rb +++ b/app/app_delegate.rb @@ -36,9 +36,15 @@ class TableViewController < UITableViewController cell.attendees_label = subview(UILabel, :cell_attendees_label, :text => "attendees #{indexPath.row}") end end
- cell.contentView.apply_constraints + cell end +
- def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
- cell.restyle!
- cell.apply_constraints
end + end
class CustomCell < UITableViewCell Unfortunately, this requires a change to the delegate, not something I can inject automatically. But you win some you lose some. My thinking is that this could be integrated easily:
class TableViewController < UITableViewController module Teacup::TableViewDelegate
...
end Would define tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath). If you need to define that method yourself, you can call super there.
class TableViewController < UITableViewController module Teacup::TableViewDelegate
def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath) super
stuff
end
...
end This is working in this branch: https://github.com/rubymotion/teacup/tree/tableview
— Reply to this email directly or view it on GitHub.
Either that, or I'm not getting how they're supposed to work. Here's a small extracted project that illustrates the problem. There should be 3 labels per cell, stacked vertically inside a small padding view. Nothing specified in the
layout
blocks seems to have a rectangle with non-zero size.https://github.com/sxross/constraint_based_table_cell