motion/project/template/ios-action-extension/files/app/action_view_controller.rb
# Disable 'IB' if you want to setup the UI in code
Disable 'IB' if you want to setup the UI in code
Disable ' IB ' if you want to setup the UI in code
def viewDidLoad
    super
    imageFound = false
    self.extensionContext.inputItems.each do |item|
      item.attachments.each do |itemProvider|
        if itemProvider.hasItemConformingToTypeIdentifier(KUTTypeImage)
          imageView = WeakRef.new(self.imageView)
          itemProvider.loadItemForTypeIdentifier(KUTTypeImage, options:nil, completionHandler: proc { |url, error|
            if url
              image = UIImage.alloc.initWithData(NSData.dataWithContentsOfURL(url))
              NSOperationQueue.mainQueue.addOperationWithBlock(proc {
                imageView.setImage(image)
              })
            end
          })
          imageFound = true
          break
        end
      end
      break if imageFound
    end
  end
def viewDidLoad super imageFound = false self . extensionContext . inputItems . each do | item | item . attachments . each do | itemProvider | if itemProvider . hasItemConformingToTypeIdentifier ( KUTTypeImage ) imageView = WeakRef . new ( self . imageView ) itemProvider . loadItemForTypeIdentifier ( KUTTypeImage , options : nil , completionHandler : proc { | url , error | if url image = UIImage . alloc . initWithData ( NSData . dataWithContentsOfURL ( url ) ) NSOperationQueue . mainQueue . addOperationWithBlock ( proc { imageView . setImage ( image ) } ) end } ) imageFound = true break end end break if imageFound end end
Disable 'IB' if you want to setup the UI in code
Disable ' IB ' if you want to setup the UI in code
# Get the item[s] we're handling from the extension context. # For example, look for an image and place it into an image view. # Replace this with something appropriate for the type[s] your extension supports. # This is an image. We'll load it, then place it in our image view.