rubymotion-community / sugarcube Goto Github PK
View Code? Open in Web Editor NEWSome sugar for your cocoa. RubyMotion helpers.
License: Other
Some sugar for your cocoa. RubyMotion helpers.
License: Other
I'm trying to convert a hash to an object, using to_object, but I keep getting a NoMethodError:
app_delegate.rb:37:in `application:didFinishLaunchingWithOptions:': undefined method `to_object' for {...}:Hash (NoMethodError)
Is the hash to object functionality still implemented?
I've required attributed string in rake file and bundles. I'm using the simple example from the README to test.
Am I doing anything wrong here?
I simply love this gem. You have done a magnificent job with it.
I did some hacking on the 'adjust.rb' and added this neat little bit.
##| CENTER (in parent frame)
# you can set 'direction' with any number of forms: 'horiz', 'vert', 'x', 'x and y'
def center(element=1, total=1, direction='horizontal', verbose=true)
@@sugarcube_view ||= nil
raise "no view has been assigned to SugarCube::Adjust::adjust" unless @@sugarcube_view
view = @@sugarcube_view
left = view.origin.x
top = view.origin.y
pwidth = view.superview.frame.width
pheight = view.superview.frame.height
left = ((pwidth - view.frame.width) * element) / (total + 1) if /hor|x/.match(direction.downcase)
top = ((pheight - view.frame.height) * element) / (total + 1) if /ver|y/.match(direction.downcase)
self.origin left, top
puts "#{view.class.name}.origin = [#{left}, #{top}]" if verbose # output in a format to be copied and pasted into your source
end
If you like what I have done, I will continue with a few more ideas and submit a proper Pull Request from a Fork.
Hi
this works :
"bla".nsdata
but this yields undefined method :
"bla".nsurl
could it be that part of sugarcube is compatible with os x, and part of it is not ?
is full compatibility with template=osx on the roadmap ?
thanks !
rake config
ERROR! Cannot find any Mac Developer certificate in the keychain
build_dir : "./build"
codesign_certificate : "Error"
copyright : "Copyright © 2013 michael. All rights reserved."
delegate_class : "AppDelegate"
deployment_target : "10.8"
embedded_frameworks : []
entitlements : {}
files : ["/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/motion-logger-0.1.3/lib/logger/version.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/motion-logger-0.1.3/lib/logger/log.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/version.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/painter.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/inspector.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/formatter.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/core_ext/object.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/core_ext/kernel.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/core_ext/class.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/awesome_print_motion-0.1.0/lib/awesome_print_motion/core_ext/array.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/calculations.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/constraint.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/core_extensions/ca_layer.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/core_extensions/view_getters.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/handler.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/layout.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/merge_defaults.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/restyle.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/stylesheet.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/stylesheet_extensions/constraints.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/stylesheet_extensions/transform.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/teacup_controller.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/teacup_util.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/teacup_view.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup/version.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/core_extensions/ns_view.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/core_extensions/ns_view_controller.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/core_extensions/ns_window.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/core_extensions/ns_window_controller.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/core_extensions/teacup_handlers.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/dummy.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/handler.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/style.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/teacup-2.1.5/lib/teacup-osx/style_extensions/autoresize.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube/adjust.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube/look_in.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube/version.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-coregraphics/core_graphics.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nserror.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nsindexpath.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nslayoutconstraint.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nsnotification.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nsset.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/nsurl.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uicolor.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uievent.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uilabel.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uitextfield.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uitouch.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uiview.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-to_s/uiviewcontroller.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-pointer/nsarray.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-nsdata/nsdata.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-nsdata/nsstring.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-nsdata/nsurl.rb", "/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sugarcube-1.1.0/lib/sugarcube-nsdata/uiimage.rb", "./app/app_delegate.rb", "./app/Controller.rb", "./app/menu.rb", "./app/styles.rb"]
framework_search_paths : []
frameworks : ["AppKit", "Foundation", "CoreGraphics"]
icon : ""
identifier : "com.yourcompany.michaelAvs"
libs : []
motiondir : "/Library/RubyMotion"
name : "michaelAvs"
pods :
resources_dirs : ["./resources", "vendor/Pods/Resources"]
sdk_version : "10.8"
short_version : "1"
specs_dir : "./spec"
version : "1.0"
weak_frameworks : []
xcode_dir : "/Applications/Xcode.app/Contents/Developer"
cobalt:michaelAvs michael$
Hi guys,
I've installed mac osx 10.9 (delete old then install new mac). When i rake project, ruby can't compile sugarcube. Please help me for this issue.
Thanks.
App crashes at startup and displays this message:
dyld: Symbol not found: _NSBackgroundColorAttributeName
Referenced from: /Users/me/Library/Application Support/iPhone Simulator/5.1/Applications/E7B7E873-43E7-46A2-81F9-E540AF42EAC1/MyApp.app/MyApp
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/UIKit.framework/UIKit
I've just started playing with SugarCube, and for the life of me I couldn't figure out how to use the REPL functionality, until I stumbled upon this:
http://motioncasts.tv/4-sugarcube-and-geomotion/
Thinking that it would be beneficial if you elaborated on your instructions for use? It's not very intuitive, particularly for newcomers.
Awesome work otherwise!
Happy to work on this myself, but not sure how to handle WRT to using new iOS7 functionality.
I'd love to use animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion
with sugarcube animations, as they really are quite addictive, and the spring functionality is really nice.
I could probably handle adding this and sending along a PR, but like I said I'm not sure what to do about iOS7.
Would there be like a separate branch and gem version for 7?
The UIControl#on method overwrites the normal UISwitch#on property. So it cannot be accessed anymore.
Using sdk 6.0 & RM 1.28 I'm getting a compile error from sugarcube:
Build ./build/iPhoneSimulator-6.0-Development
Build vendor/Pods
Compile /Users/pachun/.rvm/gems/ruby-1.9.3-p286/gems/sugarcube-0.11.3/lib/sugarcube/uiview.rb
2012-12-08 00:05:01.366 ruby[11237:f0b] unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
Can't compile stub for selector `setDuration:': unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
rake aborted!
Command failed with status (1): [/usr/bin/env VM_KERNEL_PATH="/Library/Ruby...]
Tasks: TOP => default => simulator => build:simulator
(See full trace by running task with --trace)
I'm using the attrd for a label. When uploading my App, Apple rejected it with the following message.
'Due to compatibility concerns, the NSBaselineOffsetAttributeName attribute is no longer supported in iOS 6.'
http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/
After editing the nsattributedstring.rb (ie. removing NSBaselineOffsetAttributeName references) Apple accepted the app.
Should NSBaselineOffsetAttributeName be removed from sugarcube?
Hi,
I've noticed that requiring sugarcube-nsdate
ain't enough for Fixnum#days
(i.e. 4.days
) to work.
One has to include sugarcube-timer
although that's not what's written on the NSDate wiki page.
In other words, this is a slight documentation issue for odd ducks like me who include just small portion of sugarcube in their Rakefile.
REPL stops working when using sugarcube and RubyMine and this happens:
http://bit.ly/1fek5MI
And I keep getting new views added there even when I move the cursor outside the simulator! Also, the REPL's context never changes from (main)>, except maybe to (nil)?> sometimes.
Using rake from terminal, or from RubyMine's terminal works fine, this happens just when using Run.
2013-03-10 01:13:26.110 ruby[5226:f0b] unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
Can't compile stub for selector `duration': unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
In the 'tree' command (adjust.rb) I prefer this as the puts line
puts "#{view.class.name}(##{view.object_id.to_s(16)}, #{view.frame.to_s})"
The output is more consistent with RubyMotion
I get _unrecognized runtime type CMTime
Compile /Users/rod/CitiVox/m/Vox/vendor/bundle/ruby/1.9.1/bundler/gems/sugarcube-4b507e9c5b7f/lib/sugarcube/uiview.rb
2012-09-19 12:47:39.966 ruby[21398:f0b] unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
Can't compile stub for selector `setDuration:': unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
The same happens for nsset.rb
I've just updated the gem from version 0.18.17 to the latest version and it seems something changed along the way to introduce an undefined method error when calling type on CLLocationCoordinate2D, i.e. when instantiating a pointer:
Pointer.new(CLLocationCoordinate2D.type, @locations.count)
This code results in:
undefined method `type' for CLLocationCoordinate2D:Class (NoMethodError)
Reverting back to 0.18.17 fixes the issue.
It would seem that the .uiimage method should look for .jpg files if there's no .png, so you don't have to do "foo.jpg".uiimage. I was going to add this feature, but wanted to see if there's a reason it's not there first (e.g. excessive performance penalties, etc.)
I need to call Object.const_get to change a string to a constant, but when I do, I get the following error:
013-10-04 19:06:36.373 MultiScanR[56515:a0b] uninitialized constant SugarCube::Adjust (NameError)
2013-10-04 19:06:36.377 MultiScanR[56515:a0b] *** Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant SugarCube::Adjust (NameError)
'
*** First throw call stack:
(
0 CoreFoundation 0x021275e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x005758b6 objc_exception_throw + 44
2 MultiScanR 0x0032674a _ZL10__vm_raisev + 346
3 MultiScanR 0x003267f5 rb_vm_raise + 165
4 MultiScanR 0x00257c11 rb_exc_raise + 17
5 MultiScanR 0x00254686 rb_name_error + 134
6 MultiScanR 0x002e43ab rb_mod_const_missing + 171
7 MultiScanR 0x0031ccff _ZL20dispatch_rimp_callerPFP11objc_objectS0_P13objc_selectorzEmS1_iPKm + 46303
8 MultiScanR 0x00303f93 rb_vm_dispatch + 5459
9 MultiScanR 0x002e512a rb_const_get_0 + 1210
10 MultiScanR 0x002e5160 rb_const_get + 32
11 MultiScanR 0x0031fa6a rb_vm_const_lookup_level + 282
12 MultiScanR 0x0011d9b3 vm_get_const + 227
13 MultiScanR 0x00122e42 rb_scope + 114
14 MultiScanR 0x0012689f MREP_0E65F77864BB49229D477A80B4BB585F + 7535
15 MultiScanR 0x0002d519 RubyMotionInit + 665
16 MultiScanR 0x0002d8cd main + 109
17 libdyld.dylib 0x03385725 start + 0
Any idea what might be going on?
Hello,
it seems sugarcube is not working anymore on my app.
I use uicolor method and uiimage method everywhere for setting color and image.
It worked perfectly last month, but now I got this error :
undefined method uicolor' for [...]:Array (NoMethodError) or
application:didFinishLaunchingWithOptions:': undefined method `uiimage' for "splash1.png":String (NoMethodError)
ruby 1.9.3p448 (tried with ruby-2.0.0-p247 but still the same issue)
Xcode 4.6.3 (latest from AppStore)
rubymotion 2.6
gem list
[...]
sugarcube (1.0.6)
xcodeproj (0.9.0)
Does anyone having the same issue ? or any idea of this ?
Any help would be really appreciated, thanks!
Kinny
I'm new to rubymotion and sugarcube. Just started yesterday, however I am hitting a block, I tried to use Cmd+click to repl into a view but somehow it is returning this error everytime I do that. I wonder if there is any solution to this problem?
Included sugarcube in Gemfile like this:
gem 'sugarcube', :require => 'sugarcube-all'
Hi all,
After upgrade motion to 2.0 version, i tried to run rake but get this naming error message
Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant Symbol::UIInterfaceOrientationMaskPortrait (NameError)
Does sugarcube support motion 2.0?
Please help, thanks.
The uicolor method on NSString does not work as mentioned in the README
# UIColor from color name OR image name OR hex code
"blue".uicolor == :blue.uicolor # => UIColor.blueColor
"blue".uicolor
always returns nil
.
Perhaps this behaviour is intended and the README is outdated (`:unknown_color.uicolor raises an exception, but 'unknown_color' simply returns nil)
UIButtonTypeSystem doesn't exist in iOS 6 causing my application to crash on iOS 6 with the following error:
Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant Symbol::UIButtonTypeSystem (NameError)
I traced the bug to this commit: 9643362
One solution could be to fallback to UIButtonTypeRoundedRect if not on iOS 7, like this:
defined? UIButtonTypeSystem ? UIButtonTypeSystem : UIButtonTypeRoundedRect
I'm using sugarcube-attributedstring
in a project and am loving it. However, I'm wondering if there is a way to add actions to the links in the same way I can add them to regular UILabels by using userInteractionEnabled
, UITapGestureRecognizer
, and addGestureRecognizer
. Below is an example of the NSAttributedString syntax I'm working with:
@profile.attributedText = (("Likes ".attrd +
"#{user[:activity_1]}".attrd.link("http://www.google.com").underline_color(UIColor.clearColor) +
"and " +
"#{user[:activity_2]}".attrd.link("http://www.google.com").underline_color(UIColor.clearColor)))
In the readme same typo for all the examples in the UIBarButtonItem section:
UIBarButtonitem.done does not compile--the object name has a capital I.
I am gratified that @colinta stole the in?
method from Rails and called it "my favorite" in the README. I am the original author of the Rails in?
method.
However, the way you have implemented the method is ambiguous. It's different than how Rails implemented it, despite the comment in activesupport.rb saying "These are all blatent, unapologetic rip offs of RoR extensions, and they behave in exactly the same way."
In the original pull request for in?
, several people asked for the ability to call in?(1, 2, 3)
--in other words, call it with varargs. DHH refused, and I explained why it would be a bad idea in this comment, which links to my explanation in the original lighthouse ticket.
Here's the example from the lighthouse ticket:
names = ["Brian"]
"B".in?(*names) # => true
names = ["Brian","rubyduo"]
"B".in?(*names) # => false
Because of this ambiguity, I strongly recommend you change your in?
method to be implemented the way I did it in ActiveRecord.
[Edit] Crap. Now I see that since the original implementation, someone went and changed it in Rails. Damn it. Now it's ambiguous there as well.
Well, in any case I recommend you fix it here before it's too late. The method should not allow varargs. It should look like this:
def in?(another_object)
another_object.include?(self)
rescue NoMethodError
raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
end
I'm using the https://github.com/macfanatic/promotion_slide_menu gem. If I add sugarcube, I get this error during compile:
2014-05-24 06:53:49.366 ruby[9286:d0f] unrecognized runtime type
`{PKRevealController=#@@@@@@@@@@@@@@@@@@@@@@@@iii@@{CGSize=ff}{CGSize=ff}@@?i@{?=b2b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1}}'
(TypeError)
2014-05-24 06:53:49.373 ruby[9286:d0f] *** Terminating app due to uncaught
exception 'TypeError', reason: 'unrecognized runtime type
`{PKRevealController=#@@@@@@@@@@@@@@@@@@@@@@@@iii@@{CGSize=ff}{CGSize=ff}@@?i@{?=b2b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1}}'
(TypeError)
'
*** Call stack at first throw:
(
0 CoreFoundation 0x9b4b4471 __raiseError + 193
1 libobjc.A.dylib 0x9a83c091 objc_exception_throw + 162
2 ruby 0x0017c47a rb_vm_raise_current_exception + 506
3 ruby 0x0017c562 rb_vm_raise + 226
4 ruby 0x00035201 rb_exc_raise + 17
5 ruby 0x0002e662 rb_raise + 146
6 ruby 0x00151679 _ZN13RoxorCompiler12convert_typeEPKc + 697
7 ruby 0x00155eae _ZN13RoxorCompiler12compile_stubEPKcbii + 3054
8 ruby 0x0019e9e8 _ZN16RoxorAOTCompiler20compile_static_stubsEv + 1496
9 ruby 0x001a5f09 _ZN16RoxorAOTCompiler23compile_static_bs_filesEv + 185
10 ruby 0x0014e67a _ZN16RoxorAOTCompiler21compile_init_functionERSt6vectorIPN4llvm8FunctionESaIS3_EE + 6058
11 ruby 0x0017e027 rb_vm_aot_compile + 503
12 ruby 0x000b5260 ruby_process_options + 512
13 ruby 0x00118708 main + 136
14 ruby 0x00002b35 start + 53
)
PKRevealController is a pod:
pod 'PKRevealController', '2.0.1'
I am trying to use (and understand) the new Alert you just added to SugarCube.
First, I get serious complaints about the syntax copied and pasted from the README. The same with the example code in the head of uialertview.rb
So, in troubleshooting this, I reduced it all to
UIAlert.alert("TITLE")
And that results in this very strange error message
Objective-C stub for message initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:' type
@@:@@@@@' not precompiled. Make sure you properly link with the framework or library that defines this message.
I am able to call
popup = UIAlertView.alloc.init
popup.setTitle("TITLE")
popup.addButtonWithTitle("BUTTON")
popup.show
with success.
I am stumped.
SDK 5.1 BTW
I attempted to copy and paste the fade out code from the Readme
# fade_out options
view.fade_out(0.5, delay: 0,
options: UIViewAnimationOptionCurveLinear,
opacity: 0.5) {
view.removeFromSuperview
}
For some reason it gives a wrong number of arguments (2 for 1) (ArgumentError)
Limiting this down to 1 parameter (Just the 0.5) works.
0.20.23
Time.now.getutc
=> 2013-06-21 07:10:10 UTC
Time.now.getutc.start_of_day
=> 2013-06-21 00:00:00 UTC
0.20.24
Time.now.getutc.start_of_day
=> 2013-06-21 00:00:00 +0900
Time.now.start_of_day.getutc
=> 2013-06-20 15:00:00 UTC
Time.now.getutc.start_of_day.getutc
=> 2013-06-20 15:00:00 UTC
Is it expected behavior?
What is the right way to get "2013-06-21 00:00:00 UTC" ?
In my project that has autolayout enabled, Im not getting results updating the frame when called shortly after awakeFromNib
. Are there workaround to this?
...when used in conjunction with
https://github.com/Watson1978/HelloGoogleMaps
It throws no significant errors.
with latest sugarcube, I've seen sepc failure in date_delta_spec.rb when I run `rake spec' with RubyMotion v1.32.
Bacon::Error: 2013-03-10 14:00:00 +0900.==(2013-03-10 15:00:00 +0900) failed
spec.rb:649:in `satisfy:': NSDate#delta - should handle daylight savings logically unless you assign an hour
spec.rb:663:in `method_missing:'
spec.rb:279:in `block in run_spec_block'
spec.rb:403:in `execute_block'
spec.rb:279:in `run_spec_block'
spec.rb:294:in `run'
297 specifications (1151 requirements), 1 failures, 0 errors
The following changing might fix above.
diff --git a/spec/date_delta_spec.rb b/spec/date_delta_spec.rb
index 9f53c8f..7181c21 100644
--- a/spec/date_delta_spec.rb
+++ b/spec/date_delta_spec.rb
@@ -97,7 +97,7 @@ describe "NSDate#delta" do
it "should handle daylight savings logically unless you assign an hour" do
mar_10_2012 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 13)
- mar_10_2012.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 15)
+ mar_10_2012.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 14)
end
end
Thanks.
I just created an empty new motion project with the last version of the gem 0.13
Added
require 'sugarcube'
to my app_delegate.rb
Rake
-> Got this error:
Cannot define method cgcolor' because no Objective-C stub was pre-compiled for types
^{CGColor=}@:'. Make sure you properly link with the framework or library that defines this message.
(main)> *** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 "The simulated application quit." UserInfo=0x100506650 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1}
rake aborted!
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a...]
Uninstalled 0.13 and installed 0.11, works like a charm.
I guess that the merge of issue #18 caused this error. But don't take my word on it, because it's my first day experimenting with rubymotion.
Dimitri.
I have a UIImageView that is an image of a pinata hanging from a string.
I've used the accelerometer to pass a notion of gravity into the app, such that if the user rotates the device along the x-axis, the hanging object rotates to always point towards the earth's surface.
I'd like to add a slow shake to the end of this rotation such that the movement is a bit mor fluid. The docs say that animations will always occur from the current position, but I'm finding that not to be the case, or else I'm misunderstanding the current position notion.
With the following code:
def accelerometer(accelerometer, didAccelerate:acceleration)
x = -acceleration.x
@angle = Math.atan(x)
if @angle > 15
@angle = 15
elsif @angle < -15
@angle = - 15
end
@@pinata.rotate_to(duration: 1.0, angle: (@angle)) do |complete|
@@pinata.shake offset: 0.02, duration: 2, keypath: 'transform.rotation', from_current: true
end
end
The @@pinata rotates to the proper angle as determined by the accelerometer, but then before shaking rotates back to the original angle of 0, shakes, then rotates back to where it should be as per the accelerometer.
Am I doing something wrong with the shake, the completion callback, etc.?
How can I "unsubscribe/remove a view.on_tap listener?
Is it necessary?
any one can test this? thank you :)
Is it possible to set the anchor point for a rotation?
Further, can it be set arbitrarily, as in not in reference to the view or image being rotated?
I need to set an ancor point outside of an image.
I tried something like this to no avail:
@bat.rotate_to(duration: 0.01, angle: 30.degrees, anchorPoint:[0, 1])
'test'.bold.underline
doesn't seem to work in the latest version (0.18.20)
Code like this:
SugarCube::Modal.present_modal(@create_view) do
sort_display
end
generates the "passing a block to an Objective-C method - will be ignored warning. However,
SugarCube::Modal.present_modal(@create_view)
does not generate the warning. It's not clear whether this is a Sugarcube, iOS or RM issue. It's just new and potentially bothersome. The completion is never called.
$ motion -v
1.32
Xcode: Version 4.6
Simulator: Version 6.0 (369.2)
It just throws an error:
uiimage.rb:447:in `overlay:': undefined local variable or method `new_image' for #<UIImage:0x10a84c60> (NameError)
When I try to do something like this:
"success.png".uiimage.overlay(UIColor.redColor)
@colinta You're the one who last made a change to it. Do you have a guess on what it might be?
Should there be a UIViewController.pop method to call removeFromParentViewController?
A really nice helper would be an alert()
method, so users wouldn't have to do a million UIAlertView
s:
alert 'Task completed' # alert with just the title
alert 'Task completed', with_text: 'The task you have created has been completed successfully.'
alert 'Task completed', with_cancel_button: 'Woohoo!' # Assign the cancel button
# And a lot more options in the actual UIAlertView...
i have this compiling error with the new version:
undefined method `sugarcube_cleanup' for UIControl:Class (NoMethodError)
last updates doesn't work for me:
invisible error in the terminal and application crash.
compiling with RM 2.17 and sugarcube 1.3.7 everything works perfect.
anyone else?
Disclaimer: This all is my personal position; there is a lot of personal taste involved in what I write here. So when you read "foo should be bar" please understand it as "I think that foo should be bar". I would just like the Rubymotion community to build a framework which I would love to work with; and these are my 2 cent. I wrote a number of those things down in a post to the rubymotion google group; this one here is specifically on the sugarcube API.
a)
I do like the on(:event)
methods, it reads great; but I do think, that the block should be able to receive the actual event. I do not like the off(:event)
because code like the following feels a bit asymmetrical to me:
button.on(:touch) { my_code }
button.on(:touch) { my_other_code }
button.off(:touch) # remove all handlers
I think the jQuery API has a lot to offer in how to attach event handlers and chain code and so on.
b) Symbol extensions
Symbol extensions are just, errm, not good. Why? Take this example:
:upside_down.uiorientation # => UIDeviceOrientationPortraitUpsideDown
Conceptionally, "uiorientation" is not a property of a Symbol. (Or a string, for that matter.) And there is no specific naming scheme. Do you want to know the name of the uiorientation method? Why is it called :upside_down instead of :portrait_upside_down? One would have to guess.
I understand the idea of namespacing. If you take a careful look at UIKit constants, they are all namespaced, even if in a single identifier. They are properly linked in the UIKit documentation. And when using namespacing sugarcube should stick with what ruby offers in namespacing support, namely modules; i.e. System.uifont(30)
instead of :system.uifont(30)
(which I feel is still terrible)
c)
Conversions are cool. In a ruby spirit, they should be called .to_something
instead of .something
. Whether or not keep the ui-part of the name is probably a matter of taste; I myself would prefer .to_image
instead of .to_uiimage
, but could live with the ui one.
Conversions should fail early when they are not successful; "my_image".to_image
should raise an exception if the image does not exist. (This is definitely controversial, as ruby's String#to_i, for example, just returns 0 if no part of the String can be converted; I could live very well with an additional bang-method .to_image!
)
Conversions should still be conversions only and not a fancy way of calling some method. I.e.
"my_font".to_font(20)
should not work. Why? Consider the documentation issue (i.e. b)). And where to stop: should the API provide
"my_font".to_font(20, :bold => true, :italic => true)
or should it be
"my_font".to_bold_font(20, :italic => true)
Should it support an additional "typeface" option?
d)
And is the end result more consise? This is the example from http://fusionbox.org/projects/rubymotion-sugarcube/. The 'plain' ruby version:
label = UILabel.alloc.init
label.frame = [[0, 0], [320, 40]]
label.font = UIFont.systemFontOfSize(30)
label.text = "I'm a pretty label."
label.alignment = UITextAlignmentCenter
label.textColor = UIColor.blueColor
view.addSubview(label)
label = UILabel.alloc.init
label.frame = [[40, 0], [320, 30]]
label.font = UIFont.fontWithName("Inconsolata", size:20)
label.text = "I'm a pretty label."
label.textColor = UIColor.colorWithRed(0.411765, green:0.411765, blue:0.411765, alpha:1.0) # roughly 0x696969
view.addSubview(label)
image_up = UIImage.imageNamed 'pretty_image_up.png'
image_down = UIImage.imageNamed 'pretty_image_down.png'
ok_button = UIButton.buttonWithType(UIButtonTypeCustom)
button.setImage(image_up, forState:UIControlStateNormal)
button.setImage(image_down, forState:UIControlStateHighlighted)
This is quite hackable for anyone with a fleeting interest in UIKit. You guys instead insists
"Oof, that’s a mouthful. You would hardly know it was Ruby!" and suggest instead:
label = UILabel.alloc.init
label.frame = [[0, 0], [320, 40]]
label.font = :system.uifont(30)
label.text = "I'm a pretty label."
label.alignment = :center.uialignment
label.textColor = :blue.uicolor
view << label
label = UILabel.alloc.init
label.frame = [[40, 0], [320, 30]]
label.font = "Inconsolata".uifont(20)
label.text = "I'm a pretty label."
label.textColor = :dimgray.uicolor # 0x696969.uicolor also works!
view << label
image_up = 'pretty_image_up.png'.uiimage
image_down = 'pretty_image_down.png'.uiimage
ok_button = UIButton.buttonWithType(:custom.uibuttontype)
button.setImage(image_up, forState: :normal.uicontrolstate)
button.setImage(image_down, forState: :highlighted.uicontrolstate)
which has the same amount of code, but now I would loose control :(
Please take my words as some critical input to the project; I do acknowledge the effort you put into this. I would just want the framework you are building to be one I would love to work with; and these are my 2 cent.
/eno
You can't have MessageUI and sugarcube in the same project. You get:
2012-12-13 23:26:26.618 ruby[27783:f0b] unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
Can't compile stub for selector `setDuration:': unrecognized runtime type `{_CMTime=qiIq}' (TypeError)
Hi, I'm working on ax OSX app (on OSX 10.9.2) with RubyMotion (2.27) and I require sugarcube in my rake file.
When I run "rake" command, it compiles sugarcube and my app successfully (on ruby 1.9.3-p394 and 2.1.1), but when I try to run the app, it fails with the following error:
uninitialized constant Symbol::UIUserInterfaceIdiomPhone (NameError)
Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant Symbol::UIUserInterfaceIdiomPhone (NameError)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff85bff25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff914c6e75 objc_exception_throw + 43
2 Ardumotion 0x000000010d389c41 _ZL10__vm_raisev + 337
3 Ardumotion 0x000000010d389d1d rb_vm_raise + 205
4 Ardumotion 0x000000010d28f159 rb_exc_raise + 9
5 Ardumotion 0x000000010d2897e4 rb_name_error + 228
6 Ardumotion 0x000000010d33b434 rb_mod_const_missing + 164
7 Ardumotion 0x000000010d35bfeb rb_vm_dispatch + 6139
8 Ardumotion 0x000000010d33c21c rb_const_get_0 + 972
9 Ardumotion 0x000000010ce7adc3 vm_get_const + 259
10 Ardumotion 0x000000010ce85c9f rb_scope2 + 5535
11 Ardumotion 0x000000010ce8469f rb_scope1 + 111
12 Ardumotion 0x000000010ce97de6 MREP_94163DDCDA844322A05D236996569195 + 21670
13 Ardumotion 0x000000010cd4f841 RubyMotionInit + 561
14 Ardumotion 0x000000010cd4fdfe main + 78
15 libdyld.dylib 0x00007fff8f9515fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NameError
If I remove sugarcube, everything works like a charm.
I used :light_gray.uicolor
. It shows deprecated message.
This behavior seems like the opposite.
(main)> :light_gray.uicolor
2013-08-24 00:13:10.679 irBoard[15832:1803] The symbol :lightgray has been deprecated in favor of :light_gray
2013-08-24 00:13:10.680 irBoard[15832:1803] The symbol :lightgray has been deprecated in favor of :light_gray
=> UIColor.lightGrayColor
(main)> :lightgray.uicolor
=> :lightgray.uicolor
Hi,
I am new to Rubymotion and its ecosystem. I wanted to use sugarcube's wrapper on NSAttributedString. So I installed it via Bundler.
But I am unable to use it. Even in the rubymotion repl when I type:
'test'.bold
I get this error
(main)> 'test'.bold
2014-02-26 15:55:12.550 my_app[37452:80b] undefined method `bold' for "test":String (NoMethodError)
=> #<NoMethodError: undefined method `bold' for "test":String>
Am I doing something wrong?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.