我一直在努力在Android上制作自定义相机活动,但是当旋转相机时,表面视图的纵横比会变得混乱.
在我的oncreate活动中,我设置了framelayout,它保存了显示摄像机参数的表面视图.
//FrameLayout that will hold the camera preview
FrameLayout previewHolder = (FrameLayout) findViewById(R.id.camerapreview);
//Setting camera's preview size to the best preview size
Size optimalSize = null;
camera = getCameraInstance();
double aspectRatio = 0;
if(camera != null){
//Setting the camera's aspect ratio
Camera.Parameters parameters = camera.getParameters();
List<Size> sizes = parameters.getSupportedPreviewSizes();
optimalSize = CameraPreview.getOptimalPreviewSize(sizes, getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
aspectRatio = (float)optimalSize.width/optimalSize.height;
}
if(optimalSize!= null){
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, (int)(getResources().getDisplayMetrics().widthPixels*aspectRatio));
previewHolder.setLayoutParams(params);
LayoutParams surfaceParams = new LayoutParams(LayoutParams.MATCH_PARENT, (int)(getResources().getDisplayMetrics().widthPixels*aspectRatio));
cameraPreview.setLayoutParams(surfaceParams);
}
cameraPreview.setCamera(camera);
//Adding the preview …Run Code Online (Sandbox Code Playgroud) 我正在尝试为用户点击后退按钮创建一个ruby代码块.我收到错误"未定义的方法`stringify_keys'为"/ projects/11/steps/4":字符串".当我摆脱了do和end时代码有效.如何在link_to中添加do?
<%= link_to 'Back', project_step_path(@project, @project.steps.count-1), :class => "btn btn-small" do %>
<% end %>
Run Code Online (Sandbox Code Playgroud) 我无法将视频文件转码为webm,因为我的机器无法找到libvorbis.当我运行以下命令时:
ffmpeg -y -i /public/uploads/tmp/1382112521-11953-7661/webm_Untitled.mov -vcodec libvpx -acodec libvorbis -s 640x360 -b 1500k -ab 160000 -f webm -g 30 -aspect 1.7777777777777777 /public/uploads/tmp/1382112521-11953-7661/tmpfile.webm
Run Code Online (Sandbox Code Playgroud)
我收到了错误
Unknown encoder 'libvorbis'
Run Code Online (Sandbox Code Playgroud)
我已经在我的机器上安装了libvorbis(当我尝试"brew install libvorbis时,它告诉我:警告:已经安装了libvorbis-1.3.3)".
我怎么解决这个问题?
这是完整的日志:
ffmpeg -y -i /public/uploads/tmp/1382112521-11953-7661/webm_Untitled.mov -vcodec libvpx -acodec libvorbis -s 640x360 -b 1500k -ab 160000 -f webm -g 30 -aspect 1.7777777777777777 /public/uploads/tmp/1382112521-11953-7661/tmpfile.webm
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 18 2013 12:20:19 with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared …Run Code Online (Sandbox Code Playgroud) 我有问题在父div中居中图标(垂直和水平).我的divs页面上有很多不同大小的父级,所以我希望能够按比例将图标放在每个父级div的中心.这是问题的JSFiddle:
HTML
<div class="img_container">
<i class="icon-play-circle"></i>
</div>
<br>
<div class="img_container2">
<i class="icon-play-circle"></i>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.img_container{
width:100px;
height:100px;
position:relative;
background:red;
}
.img_container2{
width:100px;
height:50px;
position:relative;
background:blue;
}
.icon-play-circle{
position:absolute;
top:45%;
left:45%;
color: white;
}
Run Code Online (Sandbox Code Playgroud) 在我的rails应用程序中,集合有许多项目,项目有很多步骤.
我想抓住集合项目中的所有步骤ID,我想知道我是否可以在一个查询中完成所有操作.
例如,我知道我可以做以下事情
step_ids = []
@collection.projects.each do |project|
project.steps.each do |step|
step_ids << step.id
end
end
Run Code Online (Sandbox Code Playgroud)
但是可以做以下事情:
@collection.projects.include(:steps).pluck("step.id") //这里的语法不正确
我正在尝试为iOS应用程序提交应用程序更新以支持运行iOS 9的设备,并且在通过XCode上传到App Store的过程中,我收到以下错误:
找不到'adamId - platform'的版本(936823648-Mac OS X App).如果此问题持续超过24小时,请与Apple代表联系.
这是一个iOS应用程序,而不是OS X应用程序,所以我不知道为什么我收到此错误.我之前已经向App Store提交了几个版本的应用程序.
有谁知道如何解决这个问题?
我正在尝试通过rails控制台更新记录并收到回滚错误:
Project.find(118).update_attributes(:featured=>true)
Project Load (2.6ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT 1 [["id", 118]]
(2.8ms) BEGIN
(1.3ms) ROLLBACK
=> false
Run Code Online (Sandbox Code Playgroud)
如何查看错误来源?我能够更新其他记录的属性,所以我想检查为什么这个特定记录不起作用.
在我的iOS应用程序中,用户可以从列表中选择一个图像,在该图像上显示一个包含图像的模态和删除图像的选项.如果用户选择删除图像,则返回到包含图像列表的原始viewController.我需要刷新原始ViewController以考虑已删除的图像.
当图像被删除到父视图控制器时,我尝试使用NSNotificationCenter进行广播.但是,似乎从未收到广播.
还有其他方法吗?
(我试着按照这里列出的例子,但它似乎没有工作)
以下是我的代码:
EditStepViewController(原始视图控制器):
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MediaPreviewViewController *mediaPreviewVC = (MediaPreviewViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MediaPreviewViewController"];
mediaPreviewVC.selectedImageURL = [NSString stringWithFormat:@"%@",gestureRecognizer.view.tag];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mediaPreviewVC];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didDismissMediaPreview)
name:@"MediaPreviewDismissed"
object:nil];
[self presentViewController:navigationController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
MediaPreviewViewController(第二个ViewController):
...
[self deleteImage];
[[NSNotificationCenter defaultCenter] postNotificationName:@"MediaPreviewDismissed" object:nil userInfo:nil];
[self dismissViewControllerAnimated:YES completion:^(){
NSLog(@"dismissed controller");
}];
Run Code Online (Sandbox Code Playgroud)
然后,回到EditStepViewController:
-(void)didDismissMediaPreview{
NSLog(@"dismissed media preview"); // this is never logged!
[self.view setNeedsDisplay]; // refresh view to account for deleted image
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
objective-c uiviewcontroller nsnotificationcenter ios presentviewcontroller
我以某种方式在Xcode中启用了TV-Out,每次运行模拟器时都会出现烦人的窗口.如何禁用/隐藏它?
我试图按照以下帖子重新加载UICollectionView中的单元格:
我知道我最终想要的东西看起来像这样:
[self.collectionView reloadItemsAtIndexPaths:??];
Run Code Online (Sandbox Code Playgroud)
但我不知道如何找到并传递特定单元格的indexPath.任何人都可以提供任何指示吗?
我有一个NSMutableArray,它包含所有单元格信息(在每个单元格中生成的imageViews).理想情况下,我想要做的是传递NSMutableArray的索引来刷新页面上的相应单元格.但我不确定数字索引如何转换为indexPath.
在此先感谢您的帮助!
ios ×3
objective-c ×2
xcode ×2
activerecord ×1
android ×1
app-store ×1
aspect-ratio ×1
associations ×1
console ×1
css ×1
ffmpeg ×1
html ×1
nsindexpath ×1
preview ×1
simulator ×1
surfaceview ×1
xcode7 ×1