小编Jed*_*Fox的帖子

如何在iPad中显示Actionsheet

UIActionsheet当我使用当前代码时,如何在iPad中显示它给我这个错误:

您的应用程序已呈现样式UIAlertController(<UIAlertController: 0x7f9ec624af70>)UIAlertControllerStyleActionSheet.在modalPresentationStyle一个UIAlertController与这种风格UIModalPresentationPopover.您必须通过警报控制器提供此弹出窗口的位置信息popoverPresentationController.你必须提供一个sourceViewsourceRectbarButtonItem.如果在显示警报控制器时不知道此信息,您可以在UIPopoverPresentationControllerDelegate方法中提供该信息-prepareForPopoverPresentation.

这在iPhone上工作得很好:

let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
let reminderAction = UIAlertAction(title: "Reminder", style: .Default, handler: {
                (alert: UIAlertAction!) -> Void in }
optionMenu.addAction(reminderAction)
self.presentViewController(optionMenu, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我遇到了一些类似的问题,解决方法是:

let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
optionMenu.popoverPresentationController?.sourceView = self.view
optionMenu.popoverPresentationController?.sourceRect = self.view.bounds
Run Code Online (Sandbox Code Playgroud)

但它并没有对我有用,可能是因为我的ActionSheet的发件人在UItableviewCell上.

我厌倦了将AlertController的Sourceview设置为tableView的Cell,但它没有正确放置,有时它部分可见这是我试过的:

optionMenu.popoverPresentationController?.sourceView = currentCell.contentView …
Run Code Online (Sandbox Code Playgroud)

ipad ios swift uialertcontroller

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

使用convert将一个图像插入另一个图像

我有一个logo.png尺寸为image的图像720x720,我希望将其拉伸或挤压以适合整个高度或宽度,并保留宽高比,并以一个有边界的矩形居中,top-left: 32,432bottom-right: 607,919在另一个background.png尺寸为size的图像中居中640x960

因此,对于上述示例,logo.png将其调整为488x488并定位在top-left: 76,432

但是我不需要计算488x48876,432,只想使用上面的top-leftbottom-right指定符,即让ImageMagick弄清楚。

ImageMagick可以做这样的事情吗?如果不能单独使用,是否有使用convert其他方法的脚本解决方案?

image-manipulation imagemagick

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

使用深度信息的对象识别算法的建议

我最近实施以下描述的技术识别软件本文.但是,我的数据集还包含使用OpenNI拍摄的深度图.

我想使用深度信息来增强识别器的稳健性.我虽然在提取VFH描述符后训练了1-vs-all SVM计算弓形响应直方图(我为此任务改编了OpenCV DescriptorExtractor接口).但重点是:我如何将两者结合起来以获得更精确的结果?有人可以建议我这个策略吗?

Ps我非常想测试识别器直接向kinect显示对象(而不是像我现在正在做的那样,将裁剪的图像提供给识别器).

opencv object-recognition depth point-cloud-library

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

如何显示分页scrollView的当前页码?

滚动视图:

<View style={{flex:1}}>
    <ScrollView
        ref={(component) => {this._scrollView = component}}
        scrollEventThrottle={15}
        removeClippedSubviews={true}
        pagingEnabled={true}
        horizontal={true}
        onScroll={this._onScroll.bind(this)}>
        {items}
   </ScrollView>
   <Text style={styles.legend}>{this.state.currentPage}/{9}</Text
</View>
Run Code Online (Sandbox Code Playgroud)

_onScroll:这个方法计算当前页号是多少

<View style={{flex:1}}>
    <ScrollView
        ref={(component) => {this._scrollView = component}}
        scrollEventThrottle={15}
        removeClippedSubviews={true}
        pagingEnabled={true}
        horizontal={true}
        onScroll={this._onScroll.bind(this)}>
        {items}
   </ScrollView>
   <Text style={styles.legend}>{this.state.currentPage}/{9}</Text
</View>
Run Code Online (Sandbox Code Playgroud)

我认为代码行没问题,但是当我平移到scrollView下一页时,它会向后滚动。一旦我删除 中的代码行_onScroll,问题就可以解决,但我无法计算当前页码。

react-native

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

如何获得dotnet Core 1.0找到System.Net.Http?

我有一个dotnet核心1.0应用程序,并尝试进行Post调用,但我遇到System.Net.Http的问题.我正在使用VSCode在OSX中开发这个应用程序.

当它尝试执行Post调用时,我在控制台中收到以下错误:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: Could not load file or assembly 'System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException: Could not load file or assembly 'System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)

我在依赖项列表末尾的project.json文件中添加了以下行,并在dotnet restore之后调用:

    "System.Net.Http": "4.1.0"
Run Code Online (Sandbox Code Playgroud)

这些是我的使用陈述:

using System;
using …
Run Code Online (Sandbox Code Playgroud)

dotnet-httpclient asp.net-core

5
推荐指数
0
解决办法
1230
查看次数

单击Google登录按钮时,iOS应用程序崩溃

我正在使用适用于iOS的Google登录库,当我单击"登录"按钮时,应用程序崩溃时出现以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
 'Your app must support the following URL schemes: <my bundleID>,
 com.googleusercontent.apps.<my client ID>'
Run Code Online (Sandbox Code Playgroud)

我检查了我的应用程序的签名版本,以确保定义了这些URL方案,它们是.
我还添加了"google"作为每个网址方案的标识符,因为我看到了Google登录示例中的操作.

这只发生在我构建我的应用程序的签名版本并在我的手机上进行临时安装时.
通过Xcode在模拟器中运行时,甚至在通过Xcode在模拟器上运行应用程序时,都不会发生这种情况.

有谁知道怎么办?

其他可能有用的信息:
我正在使用没有cocoapods的Google登录库.
我将库包和框架拖到我的项目中.

此外,我正在使用通用配置文件,其中包含应用程序ID中的通配符,出于某种原因,当我构建应用程序的签名版本时,我的应用程序的软件包ID将更改为包含通配符.
即bundle id从com.example.app更改为com.example.*.
因此,我添加了第三个包含通配符的URL方案.

xcode ios swift google-signin

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

Sequelize包括即使它是null

我使用Sequelize express和Node.js作为后端,我的sequelize中的一些数据需要包含到另一个表中但是其中一些数据为null所以我得到的整个结果是null.

问题:如果数据可用,我该如何返回一些数据,如果没有数据则返回另一个数据

router.get("/scheduled/:id", function(req, res, next) {

    models.Order.findOne({

        where: {

            id: req.params.id



        },
        attributes: ['orderStatus', 'id', 'serviceId', 'orderDescription', 'orderScheduledDate'],
        include: [{
            model: models.User,
            attributes: ['firstName', 'phoneNumber']
        }]
    }).then(function(data) {

        res.status(200).send({
            data: data,
            serviceName: data["serviceId"]
        });

    });

});
Run Code Online (Sandbox Code Playgroud)

我想:如果订单没有用户并且返回订单详细信息,那么结果应该返回null,而当它为null时,结果应该返回null.

javascript mysql orm node.js express

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

Smarty缓存无法正常工作?

当我启用缓存时,我在我的项目中使用Smarty它似乎不起作用.我使用以下结构:

index.php - display(index.tpl)

index.tpl - {include file = $ page_center}

?module = product - $ smarty-> assign("page_center","product.tpl");

在product.php中,模板product.tpl必须加载到index.tpl的中心.当我启用缓存时,它仍然显示默认内容而不是product.tpl.禁用缓存时,它可以正常工作.启用缓存时有什么问题?

php caching smarty

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

为什么setInterval只接受2 ^ 31-1个延迟值?

根据规范,

long setInterval(Function handler, optional long timeout, any... arguments);
Run Code Online (Sandbox Code Playgroud)

setInterval()应该接受long超时延迟.

但是,在64位Linux上,它的行为与签名的32位int相似.我没有在其他平台上测试,请尝试发表评论.

显而易见的问题是 - 为什么

有人可以解释为什么我会立即输出这个:

let maxSigned32 = 2147483647;
let safeInt = maxSigned32 + 1;

console.log(safeInt);
console.log(Number.MAX_SAFE_INTEGER);
console.log(safeInt < Number.MAX_SAFE_INTEGER); // true

let days = Math.round(safeInt / (1000.0 * 60 * 60 * 24));

console.log(safeInt + ' ms is ~' + days + ' days');

setTimeout(() => {
  console.log('I should not see this today')
}, safeInt);
Run Code Online (Sandbox Code Playgroud)

我在Chrome 52和Firefox 48上得到了这个(不正确的?)结果.有趣的是,当我构建并尝试使用最新的ChakraCore时,它表现得更合理.

javascript v8 spidermonkey setinterval chakra

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

在SASS/SCSS中拆分变量

我有一个SASS变量,如下所示:

$surrounding-margin: 0 40px;
Run Code Online (Sandbox Code Playgroud)

我正在使用它(不相关的属性已被删除):

#content {
  margin: $surrounding-margin;

  & #close {
    margin-right: -$surrounding-margin[1]; // If this was JS.
  }
}
Run Code Online (Sandbox Code Playgroud)

显然,-$surrounding-margin[1]不行.会是什么?我需要变量的第二个值,为负数.我怎样才能做到这一点?

css sass

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