colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
604 stars 85 forks source link

tableview cell #142

Open yestoall opened 10 years ago

yestoall commented 10 years ago

i'm having this runtime error:

layout.rb:273:in top_level_view': No default view has been defined for SearchCell. Implementtop_level_view`. (RuntimeError)

in my custom UITableViewCell class i have this

def initWithStyle style, reuseIdentifier: identifier
    super

    layout(self.contentView, :searchy) do
        @photo = subview(UIView,:cell_photo)
        @title = subview(UILabel,:cell_title)
        @year  = subview(UILabel,:cell_year)

        auto do 
            metrics "margin" => 20

            vertical "|-margin-[cell_photo(==110)]-(=>1)-|"
            vertical "|-margin-[cell_title(==20)]-margin-[cell_year(==20)]-margin-|"

            horizontal "|-margin-[cell_photo(==60)]-(=>1)-|"
            horizontal "|-margin-60-[cell_title]-margin-|"
            horizontal "|-margin-60-[cell_year]-margin-|"
        end
    end
    self.accessoryType  = UITableViewCellAccessoryNone
    self.selectionStyle = UITableViewCellSelectionStyleNone

    self
end

i don't know which parameter i need to send to my auto layout

yestoall commented 10 years ago

is anybody out there? ;)

colinta commented 10 years ago

The top_level_view method is defined for all UIView subclasses, so this error is either very strange, or easily solved by fixing SearchCell's parent class.

yestoall commented 10 years ago

is very strange... the parent class with the UITableView is also a auto layout. i can't find the bug and i'm not using auto layout to work ok.

colinta commented 10 years ago

wat? sorry, i don't follow that sentence...

If you can include the source files (the table view delegate and table cell classes should be enough) i'd be happy to take a look, see if anything jumps out at me.

yestoall commented 10 years ago

sorry about my english, my spanish is better :)

more readeable now: https://gist.github.com/yestoall/7828487

colinta commented 10 years ago

K let's see here, one thing that I notice is you are including Teacup::Layout, but that is already included by the UIView class. Not sure what happens when you include it twice, but you don't need to, anyway.

 class SearchCell < UITableViewCell
-  include Teacup::Layout
   stylesheet :search
colinta commented 10 years ago

Can you include a project that reproduces this error? I don't have time to create a project that has this same error. I'm using Teacup to create/style UITableViewCells and have never seen this error, though I suspect it's related to using the auto method.