我正在研究Zed Shaw的"学习Ruby艰苦之路"练习25
http://ruby.learncodethehardway.org/ex25.html
当我导航到保存ruby文件ex25.rb的目录并启动IRB时,我收到以下错误:
Larson-2:~ larson$ cd Ruby
Larson-2:Ruby larson$ ls
ex25.rb
Larson-2:Ruby larson$ irb
ruby-1.9.2-p290 :001 > require 'ex25'
LoadError: no such file to load -- ex25
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
ruby-1.9.2-p290 :002 >
Run Code Online (Sandbox Code Playgroud)
似乎require命令在这里不起作用.有什么我想念的吗?
我也尝试按照建议要求'./25'并得到以下错误:
Larson-2:Ruby larson$ irb
ruby-1.9.2-p290 :001 > require './ex25'
SyntaxError: /Users/larson/Ruby/ex25.rb:1: invalid multibyte char (US-ASCII)
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
Run Code Online (Sandbox Code Playgroud) 我以为我把Xcode + git问题的日子抛在身后.可能不会.我试图检查另一个分支时遇到这个git错误.
error: The following untracked working tree files would be overwritten by checkout:
RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate
RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/RCAlpha.xcscheme
RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/xcschememanagement.plist
Please move or remove them before you can switch branches.
Aborting
Run Code Online (Sandbox Code Playgroud)
很好,我说,让我删除这些文件:
andrewjl$ git rm --cached RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate
fatal: pathspec 'RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate' did not match any files
Run Code Online (Sandbox Code Playgroud)
在这一点上,我不知道该怎么做.这些文件都列在我.gitignore和我也git clean -f -d试过了.没有骰子.谁知道这里发生了什么?
我正在努力增加UINavigationBar通道的高度UIAppearance
高度本身确实发生了变化,但是条形的一部分被设备状态栏遮挡了.我想将条形向下移动22像素,以便完全可见:
[[UINavigationBar appearance] setFrame:CGRectMake([[UINavigationBar appearance] frame].origin.x, 22, [[UINavigationBar appearance] frame].size.width, 103)];
Run Code Online (Sandbox Code Playgroud)
我还设置了自动调整遮罩
[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin];
Run Code Online (Sandbox Code Playgroud)
但酒吧没有翻译.这里有另一种方式或另一步吗?
在我的集合视图布局(我的子类UICollectionViewFlowLayout)中定义了:
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我的期望是,由于旋转是一个边界变化,我的布局将重新计算.但是,当我在以下位置设置断点时:
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
Run Code Online (Sandbox Code Playgroud)
屏幕旋转时不会触发断点.有谁知道为什么?
我有一个XIB文件UIControl和UIScrollView里面的元素.我想在视图中添加背景图像.我尝试在IB中添加一个ImageView,但我不能让它作为背景出现并且它模糊了控制元素.发送sendViewBack消息似乎也没有做任何事情.
当我以编程方式创建UIImageView时,它不会显示.
以下是我尝试的代码:
程序化创作
UIImage *imageBackground = [UIImage imageWithContentsOfFile:@"globalbackground"];
UIImageView *backgroundView = [[UIImageView alloc] initWithImage:imageBackground];
[[self view] addSubview:backgroundView];
[[self view] sendSubviewToBack:backgroundView];
Run Code Online (Sandbox Code Playgroud)
处理NIB文件
[[self view] sendSubviewToBack:background];
Run Code Online (Sandbox Code Playgroud)
其中background是IBOutlet在头文件中声明并连接到IB中的NIB图像视图.
我在这里缺少一步吗?
我试图注入一个本地CSS文件来覆盖网页的样式.该网页显示UIWebView在iOS 中的容器中.但是我无法让我的代码工作.请参阅下面的委托方法的片段.这段代码运行(我可以看到NSLog消息),但我没有在页面上看到它的执行结果.
我知道它不能是我写的CSS,因为在这种情况下,我把页面自己的CSS文件,只是改变了一些颜色.(为了测试这种方法)
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *cssPath = [path stringByAppendingPathComponent:@"reader.css"];
NSString *js = [NSString stringWithFormat:@"var headID = document.getElementsByTagName('head')[0];var cssNode = document.createElement('link');cssNode.type = 'text/css';cssNode.rel = 'stylesheet';cssNode.href = '%@';cssNode.media = 'screen';headID.appendChild(cssNode);", cssPath];
[webView stringByEvaluatingJavaScriptFromString:js];
NSLog(@"webViewDidFinishLoad Executed");
}
Run Code Online (Sandbox Code Playgroud) 运行该rake db:structure:dump命令时,我遇到以下错误:
Larson-2:app larson$ rake db:structure:dump
pg_dump: server version: 9.1.3; pg_dump version: 9.0.4
pg_dump: aborting because of server version mismatch
rake aborted!
Error dumping database
Run Code Online (Sandbox Code Playgroud)
我怎样才能更新pg_dump?我安装了pg 9.1.3,有没有办法将Rails里面的引用更新到新版本?
当我尝试通过自制软件更新postgres时,我得到以下输出:
Larson-2:app larson$ sudo brew upgrade postgresql
Password:
Error: postgresql already upgraded
Run Code Online (Sandbox Code Playgroud) postgresql ruby-on-rails pg-dump postgresql-9.1 ruby-on-rails-3.2
我想在拍摄照片后避免使用/重试视图,而不会禁用让我拍照的默认Apple相机控件.
这样做:
imagePicker.showsCameraControls = NO;
Run Code Online (Sandbox Code Playgroud)
导致所有相机控件消失.还有其他方法吗?
我正在使用bootstrap-rails gem的最新master分支,并试图以与rails资产管道兼容的方式修改默认的bootstrap变量.
我的宝石文件包含了这些宝石
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'uglifier', '>= 1.0.3'
gem 'less-rails-bootstrap'
Run Code Online (Sandbox Code Playgroud)
我也包含*= require bootstrap_and_overrides在我的application.css档案中.我知道sprockets单独编译每个css文件,因此你不能指望多个css文件能够互相引用.因此,bootstrap_and_overrides.css.less文件包括以下内容:
@import "twitter/bootstrap/bootstrap";
body { padding-top: 80px; }
//background-image: asset-url("background.png"); background-repeat:no-repeat; background-size: cover; }
@import "twitter/bootstrap/responsive";
// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
// Font Awesome
@import "fontawesome";
// Your custom …Run Code Online (Sandbox Code Playgroud) ruby-on-rails-3 sprockets asset-pipeline twitter-bootstrap ruby-on-rails-3.2
假设我有一个UIImage实例,我想将其转换为数据URI并注入到UIWebView.
我知道我可以NSData使用PNGRepresentation/ JPEGRepresentation方法将UIImage转换为PNG/JPEG .但是,我如何确保转换是base64?然后如何创建一个包含实际URI和标题的字符串?
ios ×6
ios5 ×2
uikit ×2
cocoa-touch ×1
data-url ×1
git ×1
ios6 ×1
ios8 ×1
irb ×1
javascript ×1
objective-c ×1
pg-dump ×1
postgresql ×1
ruby ×1
sprockets ×1
uiappearance ×1
uicontrol ×1
uiimage ×1
uiimageview ×1
uiview ×1
uiwebview ×1
xcode ×1