form_for和form_tag有什么区别?form_remote_for和form_remote_tag有什么不同吗?
我的项目有一个UIImage类别函数,我想从另一个类调用.我正确导入图像类别的头文件,我得到项目编译没有警告.
问题是当我调用UIImage类别函数时,我看到一个无法识别的选择器错误NSInvalidArgumentException.如果我把所有东西都正确联系起来,为什么我会看到这个?
#import <UIKit/UIKit.h>
@interface UIImage (DRShare)
+ (UIImage*) imageNamed:(NSString*)name;
@end
@implementation UIImage (DRShare)
+ (UIImage*) imageNamedDR:(NSString*)name{
CGFloat s = 1.0f;
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){
s = [[UIScreen mainScreen] scale];
}
NSString *path = [NSString stringWithFormat:@"%@%@%@.png",kImagesPath,name,s > 1 ? @"@2x":@""];
return [UIImage imageWithContentsOfFile:DRBUNDLE(path)];
}
@end
Run Code Online (Sandbox Code Playgroud)
调用它的文件:
backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamedDR:@"Share Popup Background"]];
Run Code Online (Sandbox Code Playgroud)
异常提出:
2010-10-22 11:51:02.880 Stuff[11432:207] +[UIImage imageNamedDR:]: unrecognized selector sent to class 0x1f8e938
2010-10-22 11:51:02.883 Stuff[11432:207] *** Terminating app due to uncaught …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个rails应用程序,而simple_form看起来是一个非常有用的宝石.问题是我使用twitter bootstrap css来做样式,而simple_form不允许你指定html的布局.
谁能告诉我如何将simple_form html符合bootstrap css想要的格式?
我在我的mac os x计算机上安装了image magick,现在我想将它部署到heroku.我在heroku上安装了paperclip插件,但上传图片时出现此错误:
Paperclip::CommandNotFoundError
Run Code Online (Sandbox Code Playgroud)
之前我在计算机上没有imagemagick instaledl时出现此错误,但现在我想部署它,如何让图像magick在heroku上工作?
我为我的应用程序正确启用了背景音频(在plist中).在当前完成后播放下一首曲目在后台使用SPPlaybackManager(当手机被锁定/关闭时)不起作用.
当前曲目结束并且音频停止时,应用将不会开始播放下一首曲目,直到手机解锁并且我的应用再次变为活动状态.
我该如何解决?这是我用来开始播放下一首曲目的一段代码.我观察到当前曲目变为零,然后开始播放下一首曲目.日志显示我正在回放管理器对象中设置下一个当前曲目,但它是无声的.
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"spotifyPlaybackManager.currentTrack"]){
NSLog(@"%@ %@",keyPath,self.spotifyPlaybackManager.currentTrack);
if(self.spotifyPlaybackManager.currentTrack==nil && self.mode == PlayerModeSpotify){
NSLog(@"PLAY NEXT");
[self.spotifyPlaybackManager playTrack:self.nextSPTrack callback:^(NSError *error){
if(error) TKLog(@"Spotify Playback Error %@",error);
}];
}
[[NSNotificationCenter defaultCenter] postNotificationName:PlayerNowPlayingItemDidChange object:self];
return;
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
Run Code Online (Sandbox Code Playgroud)
安慰:
spotifyPlaybackManager.currentTrack (null)
PLAY NEXT
spotifyPlaybackManager.currentTrack <SPTrack: 0x60f8390>: Karaoke
Run Code Online (Sandbox Code Playgroud) 我有一个类,我想设置当我用该类调用NSLog时打印的内容.例如,
的NSLog(@ "%@",nonstandardObject);
如何设置对象以便打印出我想要的内容?
我正在捕获视频并将其转换为CGImage以对其进行处理.它将工作约10秒,获取内存警告然后崩溃(通常它说数据格式化程序暂时不可用).有人可以帮我解决问题吗?
- (void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// CONVERT CMSAMPLEBUFFER INTO A CGIMAGE
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,0);
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
CGImageRef cgimage = CGBitmapContextCreateImage(newContext);
UIImage *sourceImage= [UIImage imageWithCGImage:cgimage scale:1.0f orientation:UIImageOrientationLeftMirrored];
CGImageRelease(cgimage);
CGContextRelease(newContext);
CGColorSpaceRelease(colorSpace);
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
// ***
// Adding code after this point to do image transformation usually …Run Code Online (Sandbox Code Playgroud) 我想通过AVAssetReader读取视频样本,我遇到了各种各样的路障.可以使用应用程序包中的一个名为"Movie.m4v"的视频设置AVAsset并使用AVAssetReader循环浏览视频帧(CMSampleBufferRef).
这里有一些我现在使用的代码不起作用:
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
AVAsset *avAsset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:path] options:nil];
NSError *error = nil;
AVAssetReader *reader = [[AVAssetReader alloc] initWithAsset:avAsset error:&error]; // crashing right around here!
// I've gotten avassetreader to not crash upon initialization by grabbing an asset from the ALAssetsLibrary but it says it has 0 tracks!
NSArray *videoTracks = [avAsset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *videoTrack = [videoTracks objectAtIndex:0];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
AVAssetReaderTrackOutput *asset_reader_output = [[AVAssetReaderTrackOutput alloc] …Run Code Online (Sandbox Code Playgroud) 我已经使用PUT和html成功上传了一个文件,但有没有办法在ajax remote_form_for中上传文件?
我试过这个没有成功:
<% remote_form_for @song,:html => { :multipart => true }, :url => { :action => 'upload' } do |f| %>
Run Code Online (Sandbox Code Playgroud) 我刚升级到雪豹.之前,我把一切都运行得很好,但现在当我从终端启动服务器时,我得到:
=> Booting WEBrick
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-08-28 23:18:19] INFO WEBrick 1.3.1
[2009-08-28 23:18:19] INFO ruby 1.8.7 (2008-08-11) [universal-darwin10.0]
[2009-08-28 23:18:19] INFO WEBrick::HTTPServer#start: pid=845 port=3000
Run Code Online (Sandbox Code Playgroud)
然后当我开始生成页面时,似乎它不能与sqlite3一起使用.我该如何解决?这是当我进入脚本化视图页面时服务器打印出来的内容:
/!\ FAILSAFE /!\ Fri Aug 28 23:18:34 -0400 2009
Status: 500 Internal Server Error
uninitialized constant SQLite3::Driver::Native::Driver::API
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:105:in `const_missing'
/Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:76:in `open'
/Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:76:in `initialize'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `new'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout' …Run Code Online (Sandbox Code Playgroud) 我正在尝试上传一个MP3文件(使用回形针插件),然后立即读取MP3信息(使用Mp3Info gem),这样我就可以获得标题,歌曲长度等.
我可以使用paperclip成功上传MP3文件,但是当我尝试使用Mp3Info.open(@ song.music.url)时,我收到一条错误信息,说文件是空的.是否有正确的文件引用,以便Mp3Info可以找到该文件?
(注意实际文件位于/public/system/musics/:id/original/:filename.extention)
ActionView::TemplateError (empty file) on line #5 of app/views/songs/_upload.erb:
5: <% Mp3Info.open( @song.music.url ) do |mp3| %>
6: <% mp3.tag.title %>
7: <% end %>
Run Code Online (Sandbox Code Playgroud) 我知道mongrel是"脚本/服务器"的默认服务器,但是当我执行该命令时,我得到了webrick.(我曾经和杂种一起工作过).现在,当我告诉使用mongrel("script/server mongrel")时,服务器无法在终端中启动.我明白了:
$ script/server mongrel
^C/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/gems.rb:11:in `require': Interrupt
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:17
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:1
from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/handler.rb:17:in `const_get'
from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/handler.rb:17:in `get'
from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/handler.rb:17:in `each'
from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/handler.rb:17:in `get'
from /Users/devinross14/.gem/ruby/1.8/gems/rails-2.3.3/lib/commands/server.rb:45
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3
Run Code Online (Sandbox Code Playgroud)
我刚升级到雪豹,如果这有帮助...
我想快速获取用户"库"或播放列表中的艺术家姓名列表.有一种简单/异步的方法吗?
iphone ×3
objective-c ×3
avfoundation ×2
ruby ×2
spotify ×2
ajax ×1
camera ×1
categories ×1
cocoa ×1
cocoa-touch ×1
heroku ×1
imagemagick ×1
ios ×1
macos ×1
paperclip ×1
simple-form ×1