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

Remote images not showing on first load of Table Screen #793

Closed augustosamame closed 8 years ago

augustosamame commented 8 years ago

My Promotion table is not showing the remote images. Cell must be clicked, or the screen reloaded for the images to show. No even refreshing the table will show the images.

I have setup a basic test screen to demonstrate the issue. Switching from SDWebImage to JMImageCache pod makes no difference. The placeholder image exists in the resources folder.

class AlbumTestScreen < PM::TableScreen
  title "Your title here"
  stylesheet AlbumTestScreenStylesheet
  refreshable callback: :on_refresh,
    pull_message: "Pull to refresh",
    refreshing: "Refreshing data…"

  def on_refresh
    load_async
      end_refreshing
      update_table_data
  end

  def on_load
    @figures = []
    load_async
    update_table_data
  end

  def table_data

    [{
        cells: @figures.map do |figure|
            {
              height: 65,
              title: figure[:attributes][:face][:name],
              subtitle: figure[:attributes][:face_category][0][:name],
              remote_image: {
                url: figure[:attributes][:face][:picture],
                placeholder: image.resource('placeholder_image.png'), # NOTE: this is required!
                size: 60,
                content_mode: :scale_aspect_fill
              },
              action: :show_bio,
              arguments: figure
            }
        end
      }]

  end

  def load_async
    # Assuming we're loading tasks from some cloud service
    Figure.get(Auth.current_user["id"].to_i) do |response, figures|
      if response.success?
        @figures = figures
        update_table_data
      else
        @figures = [{attributes: {face: {name: I18n.t("album_screen.no_figures_label")}}}]
        app.alert I18n.t("album_screen.errors.unable_to_get_figures")
        mp response.error.localizedDescription if response.error
      end

    end
  end

end

This is how my table shows on first load. The images that do show are after a click on the individual cells.

image

jamonholmgren commented 8 years ago

What version of ProMotion are you using, @augustosamame ? This should have been fixed in #779. CC @andrewhavens , did #779 make it into the latest gem release?

augustosamame commented 8 years ago

I was using Promotion through Redpotion. Taking a look at my Gemfile Lock, it was version 2.6.0 Installing the ProMotion gem directly from master in my Gemfile before the redpotion gem solved the issue.

Thanks!

andrewhavens commented 8 years ago

@jamonholmgren I don't think I ever got around to releasing a new version