环境:Xcode 4,ios 5,ipod touch第4代带视网膜显示屏
我正在尝试编写一个简单的应用程序,显示视频预览并捕获照片.为了显示预览,我使用以下代码:
// Create the session
session = [[AVCaptureSession alloc] init];
// Set preset to the highest available
session.sessionPreset = AVCaptureSessionPresetPhoto;
// Give the frame for preview
CALayer *viewLayer = self.vPreview.layer;
NSLog(@"viewLayer = %@", viewLayer);
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer =
[[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.vPreview.bounds;
NSLog(@"Bounds: x:%d, y:%d,height:%d,width:%d",
self.vPreview.bounds.origin.x,self.vPreview.bounds.origin.y,
self.vPreview.bounds.size.height, self.vPreview.bounds.size.width);
[self.vPreview.layer addSublayer:captureVideoPreviewLayer];
// Get AV Device
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
// Add Input from the above device
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device …
Run Code Online (Sandbox Code Playgroud) 我见过类似的多个问题,但没有一个对我有用.
我有一个团队模型:
class Team < ActiveRecord::Base
has_one :p1, :class_name => "Player", :foreign_key => 'player_id', :validate => true
has_one :p2, :class_name => "Player", :foreign_key => 'player_id', :validate => true
end
Run Code Online (Sandbox Code Playgroud)
在我的团队的_form.html.erb中,我指的是玩家
<%= f.collection_select :p1, Player.all, :id, :name %>
Run Code Online (Sandbox Code Playgroud)
但是,在表单提交时,我看到错误:
Player(#28401456) expected, got String(#14111904)
Application Trace | Framework Trace | Full Trace
app/controllers/teams_controller.rb:47:in `new'
Run Code Online (Sandbox Code Playgroud)
Parameters:
{"utf8"=>"?",
"authenticity_token"=>"GSIcEvROFnvgGWT4HvE2VNqRw4NxU1J8iAw/WhZeRLk=",
"team"=>{"p1"=>"1"},
"commit"=>"Create Team"}
Run Code Online (Sandbox Code Playgroud)
这是代码在线
def create
@team = Team.new(params[:team])
.....
end
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
可能重复:
有人可以解释这个模板代码,它给出了数组的大小吗?
嗨,我正在看这里发布的答案:
复制到这里:
template <typename T, std::size_t N>
std::size_t size(T (&)[N])
{
return N;
}
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下(&)的重要性吗?
我是java的新手,我正在尝试从Java Generics和Collections书中理解下面的奇怪语法.(我广泛使用C++模板,因此可以声称理解泛型编程的基础知识和可能的陷阱):
interface Collection <E> {
...
public boolean addAll(Collection<? extends E> c);
...
}
Run Code Online (Sandbox Code Playgroud)
以上为什么不能写成:
interface Collection <E> {
...
public boolean addAll(Collection<T extends E> c);
...
}
Run Code Online (Sandbox Code Playgroud)
有什么不同?这只是语言限制还是引擎盖下有什么不同?
我试图了解 mongoid 中的关系,但无法超越以下内容:
class Band
include Mongoid::Document
embeds_many :photos
end
class Photo
include Mongoid::Document
embedded_in :Band
end
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,Instructing Band to embed_many phtos 将完整的照片数据存储在Band 中。但是,什么需要在 Photo 类中放入 Embedded_in 呢?如果我们不把embedded_in放在Photo里面,会不会自动多态?
此外,查询会Photo.all
获取嵌入在 Bands 中的照片吗?如果是,这是embedded_in 的原因吗?我们可以为一个班级设置多个 embedding_in 吗?
我的MapReduce
工作按日期处理数据,需要将输出写入某个文件夹结构.目前的期望是产生以下结构:
2013
01
02
..
2012
01
02
..
Run Code Online (Sandbox Code Playgroud)
等等
在任何时候,我只获得长达12个月的数据,因此,我使用MultipleOutputs
类在驱动程序中使用以下函数创建12个输出:
public void createOutputs(){
Calendar c = Calendar.getInstance();
String monthStr, pathStr;
// Create multiple outputs for last 12 months
// TODO make 12 configurable
for(int i = 0; i < 12; ++i ){
//Get month and add 1 as month is 0 based index
int month = c.get(Calendar.MONTH)+1;
//Add leading 0
monthStr = month > 10 ? "" + month : "0" + month ;
// …
Run Code Online (Sandbox Code Playgroud) 我有一个包含'字符的字符串.我想用\'替换所有这些,因为它用于插入数据库.有人可以建议我这样做的有效方法吗?不幸的是,我不能使用boost并限制为STL.
我尝试将脚本更改为以下内容,但仍然没有触发事件..我错过了什么吗?
$('#page1').live('pageshow',function(event) {
$("#radioyes").click(function(){
$("p").hide();
});
});
Run Code Online (Sandbox Code Playgroud)
我也试过,pagebeforecreate
但结果是一样.. :(
我正在尝试一个简单的jquery移动页面并测试chrome便携式.但是,在以下代码中,输入单击事件在按钮单击工作的位置不起作用.我也尝试"input#radioyes"
作为"div>fieldset>input#radioyes"
,仍然不起作用.
<!DOCTYPE html>
<html>
<head>
<title>Background check </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="images/touch-icon-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="images/touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="images/touch-icon-iphone4.png" />
<script type="text/javascript" src="jQuery/jquery.js"></script>
<script type="text/javascript" src="jQuery/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="jQuery/jquery.mobile.min.css" />
<!-- JQuery Date Picker components -->
<link rel="stylesheet" href="jQuery/jquery.ui.datepicker.mobile.css" />
<script src="jQuery/jQuery.ui.datepicker.js"></script>
<script src="jQuery/jquery.ui.datepicker.mobile.js"></script>
<link rel="stylesheet" href="css/folo.css" /> …
Run Code Online (Sandbox Code Playgroud) 我试图将json字符串解析为java对象.目前代码是手动读取文件并生成java对象.但是,我希望将实现带到gson.
这是我从Web服务调用收到的json:
{ "comment": [
"This file is used to define the behavior for the elements parsed.",
"Each entry in the file will have the format of element:name, skip:bool",
"If SkipFlag is true, it means that element need not be processed.",
"Convention used for elements and rule names is camelCase"
],
"rules": [ { "element": "html", "skip": true },
{ "element": "head", "skip": true },
{ "element": "head", "skip": true },
{ "element": "body", "skip": true }
]
}
Run Code Online (Sandbox Code Playgroud)
我需要忽略评论和转换规则.这是我试图为规则java对象定义的java类型: …
我正在尝试使用sublimetext3来编辑html.
如果我做
ul
选项卡,然后生成 <ul></ul>
如果我做
ul.temp
标签,那么它会生成<ul class="temp"></ul>
但是,当我尝试
ul>li.temp
制表符时,它正在生成ul><li class="temp"></li>
我期待看到的是 <ul><li class="temp"></li></ul>
我有包控制.在获得此功能时我缺少什么?