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

EXC_BAD_ACCESS when changing tabs afar opening new screen. #241

Closed jmonegro closed 11 years ago

jmonegro commented 11 years ago

Hey everybody,

I'm experiencing consistent crashes under the following scenario:

I should note that the 5th screen (the one that is opened) is a custom UIViewController which subclasses GKLParallaxPicturesViewController and includes the PM::ScreenModule.

Any ideas? Here's my code for the 5th screen:


class WidgetScreen < GKLParallaxPicturesViewController
  include PM::ScreenModule

  attr_accessor :widget_info_controller, :table_view

  def self.new(args = {})

    @widget_info_controller = WidgetInfo.new(nav_bar: false, widget: args[:widget])

    cover_photos = ["cover_photos/1.jpeg".uiimage, "cover_photos/2.jpeg".uiimage, "cover_photos/3.jpeg".uiimage]

    @table_view = UITableView.alloc.initWithFrame(SugarCube::CoreGraphics.Rect(0,20,320, 0), style:UITableViewStyleGrouped)

    @table_view.dataSource, @table_view.delegate = @widget_info_controller, @widget_info_controller

    @table_view.setBackgroundView UIView.alloc.init.setBackgroundColor([41,44,53].uicolor)
    @table_view.autoresizingMask = UIViewAutoresizingFlexibleHeight

    s = self.alloc.initWithImages(cover_photos, andContentView: @table_view)
    s.on_create(args)
    s
  end

  def viewDidLoad
    super
    self.view.setBackgroundColor([41,44,53].uicolor)
    self.view_did_load if self.respond_to?(:view_did_load)
  end

  def viewWillAppear(animated)
    super
    self.view_will_appear(animated) if self.respond_to?("view_will_appear:")
  end

  def viewDidAppear(animated)
    super
    self.view_did_appear(animated) if self.respond_to?("view_did_appear:")
  end

  def viewWillDisappear(animated)
    self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:")
    super
  end

  def viewDidDisappear(animated)
    self.view_did_disappear(animated) if self.respond_to?("view_did_disappear:")
    super
  end

  def shouldAutorotateToInterfaceOrientation(orientation)
    self.should_rotate(orientation)
  end

  def shouldAutorotate
    self.should_autorotate
  end

  def willRotateToInterfaceOrientation(orientation, duration:duration)
    self.will_rotate(orientation, duration)
  end

  def didRotateFromInterfaceOrientation(orientation)
    self.on_rotate
  end
end

The code that opens this screen is just a regular "open" method call. WidgetInfo is a subclass of PM::TableScreen which I'm using as a datasource for the tableview in that screen. Everything in the screen works as it should.

I'm including the custom UIViewController as a static library in my rake file like so:

app.vendor_project('vendor/GKLParallaxPicturesViewController', :static, cflags: "-fobjc-arc")

Any ideas?

Thanks!

jmonegro commented 11 years ago

Sorry, I realized this hasn't anything to do with ProMotion. Thanks anyways!

jamonholmgren commented 11 years ago

Glad you were able to fix it, @jmonegro .