小编gol*_*enk的帖子

UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?

我一直在物理iOS设备上运行我的应用程序一段时间没有任何问题.但是现在UIImagePickerController视图不会出现在模拟器上.我已经使用此处的方法将照片保存到模拟器中,并确认它们确实存在于图像库中的模拟器上.Xcode中没有弹出错误.我尝试过使用不同的源类型,但无济于事.知道我可能做错了什么吗?非常感谢!

    UIImagePickerControllerSourceType sourceType;
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
            {
                sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            }
            else
            {
                sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            }
            //Display photo library.
            [self startImagePickerControllerFromViewController: self
                                            usingDelegate: self
                                           withSourceType: sourceType];

...

- (BOOL)startImagePickerControllerFromViewController:(UIViewController*) controller
                                  usingDelegate:(id <UIImagePickerControllerDelegate,
                                                     UINavigationControllerDelegate>) delegate
                                 withSourceType:(UIImagePickerControllerSourceType) sourceType
{
    //Insure camera, controller, and delegate exist.
    if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeCamera] == NO)
        || (delegate == nil)
        || (controller == nil))
        return NO;

    //Create the ImagePicker.
    UIImagePickerController *imagePickerUI = [[UIImagePickerController alloc] init];
    imagePickerUI.sourceType = sourceType;
    //Only allow still images.
    imagePickerUI.mediaTypes = …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimagepickercontroller ios ios-simulator

4
推荐指数
1
解决办法
900
查看次数

批处理 - 如何在脚本中读取另一个命令行函数的输出?

我是批处理脚本的新手,但是,之前我做过一些bash脚本.我的批处理文件将运行另一个程序(即phpunit),该程序将输出一些东西到命令提示符.我将如何让批处理脚本拦截已经输出的东西并根据它做出决定.例如,phpunit通常会打印一个'.' 对于每个成功运行的测试,每个测试失败的"F".如何让批处理脚本捕获此输出并根据它是否看到'.'来执行不同的操作.还是'F'?

phpunit batch-file

3
推荐指数
1
解决办法
1482
查看次数

CouchDB - 一步创建带附件的文档?

我刚刚开始使用CouchDB,我已经能够使用两步过程创建带附件的文档:

$ curl -X PUT http://localhost:5984/test/small -H "Content-Type: application/json" -d {}
$ curl -X PUT http://localhost:5984/test/small/attachment?rev=1-967a00dff5e02add41819138abb3284d --data-binary @small.mp4 -H "Content-Type: video/mp4"
Run Code Online (Sandbox Code Playgroud)

我一直在寻找一下,我只看到了首次创建文档并随后添加附件的示例.有没有办法可以在一个命令中执行此操作?非常感谢!

database rest couchdb http

3
推荐指数
1
解决办法
2007
查看次数

Haskell - 列出多个参数的模式匹配?(不能构造无限型)

我在使用带有多个参数的列表模式时遇到了问题.例如,尝试定义:

somefunction (x:xs) (y:ys) = x:[y]
Run Code Online (Sandbox Code Playgroud)

结果Occurs check: cannot construct the infinite type: t0 = [t0].

基本上,我想将两个列表作为参数添加到函数中,并使用(x:xs)模式匹配方法对它们进行操作.为什么这是错的,我该怎么做呢?非常感谢!

编辑:在答案中需要使用更多代码进行更新.

somefunction a [] = [a]:[]
somefunction [] b = [b]:[]
somefunction (x:xs) (y:ys) = x:[y]
Run Code Online (Sandbox Code Playgroud)

编辑2:错过了一个重要的更新.我用上面的代码得到的错误是Occurs check: cannot construct the infinite type: t0 = [[t0]].我想我现在明白了这个问题.

haskell list pattern-matching

3
推荐指数
1
解决办法
3053
查看次数

Javascript - 在页面加载期间和仅在页面加载期间发生的Onclick事件

我仍然是javascript的新手,我找不到我犯错误的地方.我正在使用的基本设置是一组单选按钮以及一组复选框.根据所选的单选按钮,只应选择一组特定的复选框,其余的应禁用/变灰.给定单选按钮允许哪些复选框通过php数组传入.在我的代码中,独占选项指的是单选按钮,而扩展选项指的是复选框.我的javascript和php的功能如下:

window.onload = function(){
    <?php
    for($i = 0; $i < count($students_information); $i++){
        foreach($exclusive_extended_array as $exclusive => $extended){
            echo "$('".$i."_exclusive_".$exclusive."').onclick = allow(".$i.",".json_encode($extended).");";
        }
    }
    ?>
}
function allow(i, extended){
    $('[id^="'+i+'Extended"]').disabled = true;
    for (var j = 0; j < extended.length; j++) {
        alert(extended[j]);
        $(i+"Extended"+extended[j]).disabled = false;
    }
}
Run Code Online (Sandbox Code Playgroud)

在加载的页面上,它显示为:

<script type="text/javascript">
window.onload = function(){
    $('0_exclusive_2176').onclick = allow(0,[1975]);
    $('0_exclusive_911').onclick = allow(0,[]);
    $('0_exclusive_795').onclick = allow(0,[1973,1975]);
}
function allow(i, extended){
    $('[id^="'+i+'Extended"]').disabled = true;
    for (var j = 0; j < extended.length; j++) {
        alert(extended[j]); …
Run Code Online (Sandbox Code Playgroud)

javascript php onclick onload

2
推荐指数
1
解决办法
1096
查看次数

AVFoundation - 如何将AVCaptureMovieFileDataOutput保存到文件中?

我一直在阅读AV基金会编程指南.特别是我一直试图让"媒体捕获"部分的"全部放在一起"部分工作.我对本教程中的代码进行了一些小的更改,但没有什么应该产生太大的影响.我对它如何从AVCaptureMovieFileDataOutput实际保存电影文件感到困惑.我使用以下内容设置捕获会话:

//Create session.
AVCaptureSession *session = [[AVCaptureSession alloc] init];

//Set preset to low.
if ([session canSetSessionPreset:AVCaptureSessionPresetLow]) {
    session.sessionPreset = AVCaptureSessionPresetLow;
}
else {
    // Handle the failure.
}

//Get camera device.
AVCaptureDevice *device =
[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

NSError *error = nil;
AVCaptureDeviceInput *input =
[AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
if (!input) {
    //Handle the error appropriately.
}
[session addInput:input];

//Create output.
AVCaptureMovieFileOutput *output = [[AVCaptureMovieFileOutput alloc] init];
[session addOutput:output];

[session startRunning];
Run Code Online (Sandbox Code Playgroud)

我可能只是在开发人员文档中遗漏了一些我没有看到的内容,但我还没有看到如何实际获取会话来创建文件.有什么建议?非常感谢!

objective-c avfoundation ios avcapturesession avcapturemoviefileoutput

2
推荐指数
2
解决办法
3921
查看次数

替换{{super()}}中的块

我有一个基本模板,其中包含默认<head>内容的块.在头部区域内,有一个区块<title>.

例如,在基本文件中我会:

<head>
    {% block head %}
    {% block title %}<title>An App</title>{% endblock title %}
    <script src="somescript.js"></script>
    {% endblock head %}
</head>
Run Code Online (Sandbox Code Playgroud)

在子模板中,我想从基数中包含头块中的所有内容(通过调用{{ super()) }}并包含一些其他内容,但同时替换超级调用中的标题块.

有没有办法做到这一点,而不只是围绕头部内容的其余部分(不包括标题),并只是替换所有这些?

python templates jinja2

2
推荐指数
1
解决办法
6856
查看次数

期望 - expect_user的不同超时和期望?

我希望有一个无限(或非常大)的超时expect_user和默认超时expect.有没有办法设置不同的超时?或者我只需要在每次使用更改之前手动执行此操作?

expect

2
推荐指数
1
解决办法
941
查看次数

JQuery - 包括JQuery会导致警报无法运行?

我正在尝试运行下面给出的代码(我已经简化了以解决问题).当我排除src脚本的部分(即省略了JQuery的源代码)时,警报将正常运行,但会导致错误Uncaught TypeError: Object #<HTMLImageElement> has no method 'offset'.这是因为JQuery没有被包括在内.但是,当我添加该src部分时(如下所示),我没有得到任何错误或警告,但代码并没有尽我所能.具体来说,没有警报(或其他任何东西).我猜我只是在如何包含JQuery时犯了一些愚蠢的错误,但我不确定它是什么.有什么建议?非常感谢!

<script src="/js/jquery-2.0.3.min.js" type="text/javascript" >      
  getPosition = function() {
    var the_source = document.getElementById('the_source');
    var offset = the_source.offset();
    var x_position = e.clientX - offset.left;
    var y_position = e.clientY - offset.top;
    alert(e.clientX - offset.left);
    alert(e.clientY - offset.top);
  }

  initialize = function() {
    alert('check');
    getPosition();
  }      

  setTimeout(initialize, 100);
</script>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
1
解决办法
71
查看次数

Haskell - 在"无法匹配预期类型"的情况下的模式匹配

我有一个类似于的自定义数据类型:

data Token = Number Int
           | Otherthings
Run Code Online (Sandbox Code Playgroud)

我希望能够以一种方式使用"数字"而在另一种方式中使用其他东西.所以我可以成功创建一个case语句,如:

parse x = case x of
    Number y -> y
Run Code Online (Sandbox Code Playgroud)

然后成功地采取:

let x = Number 7 in parse x
Run Code Online (Sandbox Code Playgroud)

并评估为7.但是,当我尝试将"解析"功能更改为:

parse [] = []
parse (x:xs) = case x of
    Number y -> y
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Couldn't match expected type `[a0]' with actual type `Int'
In the expression: y
In a case alternative: Number y -> y
In the expression: case x of { Number y -> y }
Run Code Online (Sandbox Code Playgroud)

为什么这不能以这种方式工作以及解决这个问题的正确方法是什么?非常感谢!

haskell pattern-matching case-statement

1
推荐指数
1
解决办法
1275
查看次数