jamonholmgren / ProMotion

ProMotion is a RubyMotion gem that makes iPhone development less like Objective-C and more like Ruby.
MIT License
1.26k stars 147 forks source link

Table cell font size? #11

Closed mstanislav closed 11 years ago

mstanislav commented 11 years ago

Any hints on setting a font size for table cell data with promotion? Thanks!

jamonholmgren commented 11 years ago

The best way probably is to subclass UITableViewCell and then set it via your table_data method:

UITableViewCell docs: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html

Setting the custom cell type:

def table_data
  [{
    title: "My Header",
    cells: [
      { title: "Something", cellClass: MyCustomTableViewCell, action: :some_action }
    ]
  }]

end

NOTE: cellClass will become cell_class in ProMotion 0.4, coming out soon, like next week. cellClass will work but will be deprecated.

jamonholmgren commented 11 years ago

You can also use Teacup with ProMotion.

https://github.com/rubymotion/teacup

mstanislav commented 11 years ago

Thanks for the follow-ups! Really enjoying the gem.

jamonholmgren commented 11 years ago

No problem -- glad it's useful to you!

mstanislav commented 11 years ago

FYI, I inelegantly added a workaround for this in my case by adding: dataCell[:font_resize] ||= false tableCell.textLabel.adjustsFontSizeToFitWidth = dataCell[:font_resize]

That was all I really needed to accomplish!