Last active
December 20, 2015 04:28
-
-
Save GantMan/6070832 to your computer and use it in GitHub Desktop.
Accompanying code for my SocialFramework in RubyMotion blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project/template/ios' | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'SocialFramework' | |
# Old way was to include the Twitter framework here | |
app.frameworks += ["Social", "Accounts"] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THIS IS HOW TO DO IT REAL QUICK WITH SUGARCUBE | |
# https://github.com/rubymotion/sugarcube | |
@buttons = ['Cancel', nil, 'Camera Roll'] | |
UIActionSheet.alert(nil, buttons: @buttons, | |
cancel: proc {p "Cancel - doing nothing is ok" }, | |
destructive: nil, | |
success: proc do |pressed| | |
if @social_options.include? pressed | |
social_media_post(@social_options[pressed]) | |
elsif pressed == 'Camera Roll' | |
p "Save to camera roll" | |
end | |
end | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sheet = UIActionSheet.alloc.initWithTitle(nil, | |
delegate:self, | |
cancelButtonTitle:nil, | |
destructiveButtonTitle:nil, | |
otherButtonTitles:nil) | |
@buttons.each do |btn| | |
sheet.addButtonWithTitle(btn) | |
end | |
sheet.cancelButtonIndex = sheet.addButtonWithTitle('Cancel') | |
sheet.showInView(view) | |
# ... rest of your parent method (e.g. viewDidLoad), then handle the delegate | |
def actionSheet(sheet, didDismissWithButtonIndex:buttonIndex) | |
button = @buttons[buttonIndex] | |
social_media_post(@social_options[button]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment