我正在尝试获取日期时间的UTC偏移量.日期时间保存为:
星期五,2013年5月31日15:19:08 EDT -04:00
我想得到的是"-04:00".当我这样做时object.utc_offset,我明白了-14400.我应该使用什么功能?
我在我的Android应用程序中创建了一个带有EditText的AlertDialog,但默认的边距看起来真的很糟糕.我试图指定边距如下:
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(SpinActivity.this);
builder.setTitle("Edit Spin Tags");
builder.setMessage("(separate tags with commas)");
// set input
int margin = 10;
final EditText input = new EditText(SpinActivity.this);
input.setSingleLine();
input.setText(spinTags.toString().replace("[", "").replace("]", ""));
builder.setView(input, margin, 0, margin, 0);
Run Code Online (Sandbox Code Playgroud)
但是,从下图中可以看出它没有应用所需的效果.
其他选项我试过包括将在LinearLayout中输入和设置使用的LayoutParams设置AlertDialog欣赏到的LinearLayout前的利润.
如何在AlertDialog中设置EditText的边距?
我正在使用Google Maps API v2,并尝试将参考ID嵌入到标记信息窗口中.当用户单击信息窗口时,它应该将引用ID传递给新的意图.
我实际上并不希望用户可以看到引用ID.我将引用ID添加为代码段并使用marker.getSnippet()来获取要传递给新活动的引用ID.有没有办法隐藏代码段,以便用户看不到它?
我在我的Rails应用程序中使用Devise并且遇到重置密码的问题.
当我尝试重置密码时,我发送了一封电子邮件,其中包含重置密码的链接.在使用新密码填写表单后,我在Chrome中收到错误"网页有重定向循环",我的日志中出现以下错误:
Started GET "/users/password/edit?reset_password_token=[FILTERED]" for 127.0.0.1 at 2013-12-19 14:22:05 -0500
Processing by Devise::PasswordsController#edit as HTML
Parameters: {"reset_password_token"=>"[FILTERED]"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Redirected to http://localhost:3000/users/password/edit?reset_password_token=JatMT1fE-fQwsCWsEdy6
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 1.8ms (ActiveRecord: 0.4ms)
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到有关如何解决此问题的任何信息.
user.rb
class User < ActiveRecord::Base
...
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:token_authenticatable, :confirmable, :lockable
...
end
Run Code Online (Sandbox Code Playgroud)
devise.rb
Devise.setup do |config|
...
config.reset_password_within = 6.hours
...
end
Run Code Online (Sandbox Code Playgroud)
的routes.rb
Build::Application.routes.draw …Run Code Online (Sandbox Code Playgroud) 有没有相当于Android View.GONE的iOS?
在Android中,将视图设置为GONE将使其不可见,并确保视图不会占用布局中的任何空间.我知道在iOS中,你可以设置一个隐藏的视图
[viewName setHidden:true];
Run Code Online (Sandbox Code Playgroud)
但是视图仍然占用了布局中的空间,我认为完全删除视图并在以后重新创建它是没有效率的.
(注意:我看过这篇文章:iOS相当于Android View.GONE可见性模式,但是没有接受的答案,并且将高度设置为0对我来说不起作用,因为页面上的后续视图在我之后没有移动视图已删除)
我刚刚升级到OS X Yosemite,并且遇到了运行我的Rails应用程序的各种问题.我经常看到以下错误:
ruby(11958,0x7fff7e430300) malloc: *** error for object 0x7f880b801808: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这一问题?
编辑
我尝试按照此页面上的建议操作:
如何让Ruby/Homebrew/RVM在Yosemite上运行?
但是当我编辑brew.rb将路径更改为"Current"时,我收到错误:
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
Run Code Online (Sandbox Code Playgroud)
解
我完全删除了rvm并从头开始重新安装.为了删除rvm,我首先必须运行
rvm fix-permissions
Run Code Online (Sandbox Code Playgroud)
然后
rvm implode
Run Code Online (Sandbox Code Playgroud)
然后我按照本页面上的说明操作:
在我的iOS应用程序中,我想让用户发推文GIF.
我有一个工作TWTRComposer并尝试使用SetImage方法附加GIF:
[composer setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:self.localGifURL]]];
Run Code Online (Sandbox Code Playgroud)
然后图像出现在作曲家视图中,但是当图像发布到Twitter时,它是静态图像而不是GIF.
是否可以将GIF附加到使用TWTRComposer创建的推文上?
编辑
我尝试集成这个库来创建动画UIImage:
https://github.com/mayoff/uiimage-from-animated-gif
更新我的代码,我有以下内容:
[composer setImage:[UIImage animatedImageWithAnimatedGIFURL:self.localGifURL]];
Run Code Online (Sandbox Code Playgroud)
但这仍然导致Twitter上的静态图像.
编辑#2
另一个观察 - 如果我将GIF保存到我的手机并尝试直接从照片库(打开看起来像TWTRComposer窗口)在Twitter上分享它,它会发布为图像,而不是GIF.这导致我可能无法将GIF附加到TWTRComposer ...
我有一个宝石的问题,发现有人能够在这个拉取请求中修复它:
https://github.com/rheaton/carrierwave-video/pull/13
如何将此更改集成到我的应用程序本地,因为它已合并?
我试图为我的Heroku Rails应用程序安装ffmpeg,现在我的应用程序崩溃了.
我使用以下命令添加了一个buildpack:
heroku config:add BUILDPACK_URL=https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
Run Code Online (Sandbox Code Playgroud)
推送到Heroku后,根据我的日志得到以下错误:
2013-11-17T17:50:44.022351+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 47171`
2013-11-17T17:50:46.295602+00:00 app[web.1]: bash: bundle: command not found
2013-11-17T17:50:47.589491+00:00 heroku[web.1]: Process exited with status 127
2013-11-17T17:50:47.597968+00:00 heroku[web.1]: State changed from starting to crashed
2013-11-17T17:50:48.620853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ (...) fwd="76.118.180.235" dyno= connect= service= status=503 bytes=
2013-11-17T17:50:48.847288+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=(...) fwd="76.118.180.235" dyno= connect= service= status=503 bytes=
Run Code Online (Sandbox Code Playgroud)
当我运行heroku运行rake db:migrate时,我收到错误:
Running `rake db:migrate` attached to …Run Code Online (Sandbox Code Playgroud) 在我的Android应用程序中,我创建了一个WebView来播放Vimeo视频.当我加载活动时,会显示vimeo视频的正确预览,但是当我尝试播放时,我会看到以下屏幕:

有时视频中的音频播放,但我从未收到视频.以下是我的活动内容:
if(mediaURL.toLowerCase().contains("vimeo")){
Log.d(TAG, "adding viemo");
final WebView vimeoPlayer = new WebView(MediaPreview.this);
vimeoPlayer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
vimeoPlayer.getSettings().setJavaScriptEnabled(true);
vimeoPlayer.getSettings().setLoadWithOverviewMode(true);
vimeoPlayer.getSettings().setUserAgentString("Android Mozilla/5.0 AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
vimeoPlayer.setWebChromeClient(new WebChromeClient());
vimeoPlayer.setWebViewClient(new WebViewClient());
vimeoPlayer.getSettings().setAppCacheEnabled(true);
vimeoPlayer.getSettings().setDomStorageEnabled(true);
vimeoPlayer.getSettings().setPluginState(PluginState.ON);
vimeo_url = mediaURL + "?player_id=player&title=0&byline=0&portrait=0&api=1&maxheight=480&maxwidth=800";
Log.d(TAG, "vimeo_url: " + vimeo_url);
vimeoPlayer.loadUrl(vimeo_url);
// vimeoPlayer.loadDataWithBaseURL("", vimeo_url, "text/html", "UTF-8", null);
mediaHolder.addView(vimeoPlayer);;
}
Run Code Online (Sandbox Code Playgroud)
我还没有看到在Android应用中使用Vimeo播放器的任何明确示例,所以如果有人让这个工作,那么非常感谢你的帮助!