Ruby Motion附带了许多预构建的函数,其格式如下:
def tableView(tv, numberOfRowsInSection:section)
# blah
end
Run Code Online (Sandbox Code Playgroud)
我想这样做我自己的功能; 人为的例子:
class Timeser
def multiplyNumber(one byNumber:two)
one*two
end
end
Run Code Online (Sandbox Code Playgroud)
这段代码不会在ruby motion 1.0下编译...有没有办法做到这一点?如果是这样,怎么样?
我想通过usine在ios6上打开地图,MKMapItem但我也喜欢使用谷歌地图为较旧的ios版本进行后备...
我没有想法在没有BubbleWrap的情况下在rubymtion上执行此操作会导致Device.ios_version返回错误
我想在iOS6上这个:
address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
mapItem = MKMapItem.alloc.initWithPlacemark(place)
mapItem.name = "#{@party.name}"
options = ({
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
})
mapItem.openInMapsWithLaunchOptions(options)
Run Code Online (Sandbox Code Playgroud)
这在旧版本上:
url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
App::open_url(url)
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
然后当我做正确的测试时:当我进行测试并在IOS 5.1上运行它时出现此错误
dyld: Symbol not found: _MKLaunchOptionsDirectionsModeDriving
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
if Utils.older_than_ios6?
url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
App::open_url(url)
else
address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
mapItem = MKMapItem.alloc.initWithPlacemark(place)
mapItem.name = "#{@party.name}"
options = ({
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
})
mapItem.openInMapsWithLaunchOptions(options)
end
Run Code Online (Sandbox Code Playgroud) 自从我更新了我的XCode之后,MinimumTrackImage我的UISlider现在正在拉伸,就像我想要它之前一样.这种MaximumTrackImage行为没有改变.
怎么才能MinimumTrackImage伸展?请注意,我使用rubymotion,但使用obj-c的解决方案也是可以接受的.
我真的陷入了一个Core Data我似乎无法解决的错误:
Can't migrate SQLite store: Error Domain=NSCocoaErrorDomain Code=134110 The operation couldn’t be completed. (Cocoa error 134110.) UserInfo=0xab4b630 {NSUnderlyingError=0xab4b2e0 The operation couldn’t be completed. (Cocoa error 516.), reason=Can't copy source store to destination store path
Run Code Online (Sandbox Code Playgroud)
我找不到有关此错误的任何资源...
它是一个非常简单的迁移,只有一个模型"User"具有name属性和created_by属性,对于我的测试我没有改变任何东西,两个模型是相同的.我只想让它发挥作用.有任何想法吗?
我简单的RubyMotion代码:
data = DataParser.parse(url)
error_ptr = Pointer.new(:object)
json = NSJSONSerialization.JSONObjectWithData(data, options: 0, error: error_ptr)
Run Code Online (Sandbox Code Playgroud)
url是一个天气API,提供JSON温度如浮点数{ "temp_c":22.4, ... }.奇怪的是,浮动22.4转换为22.3999938964844.
如果我检查data.to_s温度读数22.4,那么我认为错误在于NSJSONSerialization.JSONObjectWithData.
我不想强迫所有花车四舍五入.
我在iOS 7中使用视图控制器时出现问题.我正在尝试找出在导航栏和状态栏下调整视图布局的最佳方法,同时保持导航栏的透明度/模糊.例如,如果我有一个视图控制器:
def viewDidLoad
@scroll = UIScrollView.alloc.initWithFrame(new_frame)
@scroll.bounces = true
@scroll.delegate = self
@scroll.alwaysBounceVertical = true
@scroll.scrollsToTop = true
@scroll.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)
self.view.addSubview(@scroll)
end
Run Code Online (Sandbox Code Playgroud)
我的内容显示在导航栏下,我获得了iOS 7过渡指南.要纠正这个问题,如果我在viewDidLoad中添加以下内容:
self.edgesForExtendedLayout = UIRectEdgeNone
布局已调整,但导航栏不再具有透明度或模糊,因为视图不会在其后面延伸.
如果我不调整scrollView insets而不是设置layout的边缘:
self.automaticallyAdjustsScrollViewInsets = false
然后将我的滚动框更改为:
def viewDidLoad
nav_bar_height = self.navigationController.navigationBar.frame.size.height
status_height = UIApplication.sharedApplication.statusBarFrame.size.height
height = nav_bar_height + status_height
scroll_frame = self.view.bounds
new_frame = CGRect.new([0, height], [scroll_frame.size.width, scroll_frame.size.height])
@scroll = UIScrollView.alloc.initWithFrame(new_frame)
@scroll.bounces = true
@scroll.delegate = self
@scroll.alwaysBounceVertical = true
@scroll.scrollsToTop = true
@scroll.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)
self.view.addSubview(@scroll)
end …Run Code Online (Sandbox Code Playgroud) 我不使用Xcode来构建我的IPA.我尝试搜索苹果文档,但我无法找到所有可能的系统功能的关键值.为了不懒惰,我还试图将打开了这些功能的项目归档,并通过IPA进行搜索,但无法找到Xcode6隐藏这些权利的位置.
对于使用Xcode6的用户,这些是此处列出的功能

由于我手动生成IPA,我需要知道这些键是什么,以匹配我的应用程序标识符上设置的功能.
更新
以下是关键值,它们实际上在project.pbxproj文件中,感谢@colinta的帮助
SystemCapabilities = {
com.apple.ApplicationGroups.iOS = {
enabled = 1;
};
com.apple.BackgroundModes = {
enabled = 1;
};
com.apple.DataProtection = {
enabled = 1;
};
com.apple.GameCenter = {
enabled = 1;
};
com.apple.HealthKit = {
enabled = 1;
};
com.apple.HomeKit = {
enabled = 1;
};
com.apple.InAppPurchase = {
enabled = 1;
};
com.apple.InterAppAudio = {
enabled = 1;
};
com.apple.Keychain = {
enabled = 1;
};
com.apple.Maps.iOS = {
enabled = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种使用base64编码字符串的简单方法.在ruby运动中,我不能只使用Ruby的Base64encode,因为我无法要求它.所以我认为我可以使用Cocoa的功能构建.但Cocoa似乎没有Base64encode功能.我在NSData上找到了一些类别,但不知道如何在ruby motion项目中使用它们.我应该为此创建一个静态库吗?
我觉得我看错了方向,必须有一个简单的解决方案吗?
我在Rubymotion项目的资源/文件夹中有一些数据文件.如何在代码中访问它们?没有路径访问它们是行不通的.
例如,我在资源中有一个文件/名为schema.json
这是我正在使用的代码:
NSData.dataWithContentsOfFile("schema.json") <--- returns nil
Run Code Online (Sandbox Code Playgroud) 我正在使用RubyMotion和ProMotion gem开发iOS应用程序.如何使用ProMotion创建自定义表格单元格?如果我使用内置的表格屏幕,我只能使用默认的iOS样式,这不是很有用.
我添加了这个在不使用ProMotion时工作的功能.但是,当我在ProMotion屏幕上使用它时,它不会触发:
def tableView(tableView, cellForRowAtIndexPath:indexPath)
...
end
Run Code Online (Sandbox Code Playgroud)