ios - undefined method `initWithNibName' -
i have started learning ios development rubymotion , i'm doing tutorial. seems pretty easy understand, right i'm stuck error when run rake
command:
colorcontroller.rb:7:in `initwithcolor:': undefined method `initwithnibname' #<colorcontroller:0x9b4f470> (nomethoderror) searchcontroller.rb:46:in `open_color:' color.rb:35:in `block in find:' query.rb:358:in `call_delegator_with_response' query.rb:128:in `connectiondidfinishloading:'
i got part whew ton of code isn't it.
found on tutorial page , i'm stuck there. code looks like:
# app_delegate.rb class appdelegate def application(application, didfinishlaunchingwithoptions:launchoptions) @window = uiwindow.alloc.initwithframe(uiscreen.mainscreen.bounds) @search_controller = searchcontroller.alloc.initwithnibname(nil, bundle: nil) @navigation_controller = uinavigationcontroller.alloc.initwithrootviewcontroller(@search_controller) @window.rootviewcontroller = @navigation_controller @window.makekeyandvisible true end end # colorcontroller.rb class colorcontroller < uiviewcontroller attr_accessor :color def initwithcolor(color) initwithnibname(nil, bunlde: nil) self.color = color self end def viewdidload super self.title = self.color.hex @info_container = uiview.alloc.initwithframe [[0, 0], [self.view.frame.size.width, 110]] @info_container.backgroundcolor = uicolor.lightgraycolor self.view.addsubview @info_container @color_view = uiview.alloc.initwithframe [[10, 10], [90, 90]] @color_view.backgroundcolor = string.new(self.color.hex).to_color self.view.addsubview @color_view @color_label = uilabel.alloc.initwithframe [[110, 30], [0, 0]] @color_label.text = self.color.hex @color_label.sizetofit self.view.addsubview @color_label @text_field = uitextfield.alloc.initwithframe [[110, 60], [100, 26]] @text_field.placeholder = "tag" @text_field.textalignment = uitextalignmentleft @text_field.autocapitalizationtype = uitextautocapitalizationtypenone @text_field.borderstyle = uitextborderstyleroundedrect self.view.addsubview @text_field @add_button = uibutton.buttonwithtype(uibuttontyperoundedrect) @add_button.settitle("add", forstate: uicontrolstatenormal) @add_button.settitle("adding", forstate: uicontrolstatedisabled) @add_button.settitlecolor(uicolor.lightgraycolor, forstate: uicontrolstatedisabled) @add_button.sizetofit @add_button.frame = [[@text_field.frame.origin.x + @text_field.frame.size.width + 10, @text_field.frame.origin.y], @add_button.frame.size] self.view.addsubview(@add_button) table_frame = [[0, @info_container.frame.size.height], [self.view.bounds.size.width, self.view.bounds.size.height - @info_container.frame.size.height - self.navigationcontroller.navigationbar.frame.size.height]] @table_view = uitableview.alloc.initwithframe(table_frame, style: uitableviewstyleplain) self.view.addsubview(@table_view) end end # searchcontroller.rb class searchcontroller < uiviewcontroller def viewdidload super self.title = "search" self.view.backgroundcolor = uicolor.whitecolor @text_field = uitextfield.alloc.initwithframe [[10, 10], [self.view.frame.size.width - 20, 30]] @text_field.placeholder = "#abcabc" @text_field.textalignment = uitextalignmentleft @text_field.autocapitalizationtype = uitextautocapitalizationtypenone @text_field.borderstyle = uitextborderstyleroundedrect @text_field.center = cgpointmake(self.view.frame.size.width / 2, self.view.frame.size.height / 2 - 100) self.view.addsubview @text_field @search_button = uibutton.buttonwithtype(uibuttontyperoundedrect) @search_button.settitle("search", forstate: uicontrolstatenormal) @search_button.settitle("loading", forstate: uicontrolstatedisabled) @search_button.sizetofit @search_button.center = cgpointmake(self.view.frame.size.width / 2, @text_field.center.y + 40) self.view.addsubview @search_button @search_button.when(uicontroleventtouchupinside) @search_button.enabled = false @text_field.enabled = false hex = @text_field.text hex = hex[1..-1] if hex[0] == "#" color.find(hex) |color| if color.nil? @search_button.settitle("none :(", forstate: uicontrolstatenormal) else @search_button.settitle("search", forstate: uicontrolstatenormal) self.open_color(color) end @search_button.enabled = true @text_field.enabled = true end end end def open_color(color) self.navigationcontroller.pushviewcontroller(colorcontroller.alloc.initwithcolor(color), animated: true) end end
i have 2 models i'm sure not relevant unless you're going run code.
can tell me supposed ? realise i'm trying call initwithnibname
method not defined on class, tutorial assumed it's correct. need define on colorcontroller
class ? or can call in other way ?
you spelled bundle incorrectly.
change:
initwithnibname(nil, bunlde: nil)
to:
initwithnibname(nil, bundle: nil)
Comments
Post a Comment