我有UICollectionView和UIImageView(如图所示).
我想把它作为圆形视图.但是,当我运行应用程序时,它显示为菱形(下图).
在(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
我设置为
[cell.photo setImageWithURL:[NSURL URLWithString:url] usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
cell.photo.layer.cornerRadius = cell.photo.bounds.size.width / 2;
cell.photo.layer.masksToBounds = NO;
cell.photo.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)
对于设置图像,我使用了libs SDWebImage
而且我确定,cornerRadius值是正确的(它是图像宽度的一半).此外,我没有在故事板属性中进行任何手动更改(位置设置为自动布局).我错过了什么?
我想让我的一些查询参数是可选的.至于现在,我有
r.HandleFunc("/user", userByValueHandler).
Queries(
"username", "{username}",
"email", "{email}",
).
Methods("GET")
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,"用户名"和"电子邮件"需要出现在请求中.我想有更灵活的选择:有2个或只有其中一个(但不是零参数).
谢谢!
我有一个问题来存根对 DynamoDB 的调用以进行 API 测试。我正在使用无服务器 mocha 并希望从端到端的角度测试我的 API。项目结构并不简单,但在 API 文件本身内部,我单独调用了不同的类文件以实际使用 DynamoDB 函数。让我们假设它是一个图书馆。因此,我不能使用 aws-sdk-mock,因为要求“AWS 服务需要在被测试的函数内初始化,以便模拟 SDK 方法”不是我的情况。如何测试我的 API 并存根对 DynamoDB 的调用?现在测试实际上正在运行,但它对我想避免的数据库进行了真正的调用:
const isStub = true;
const mochaPlugin = require('serverless-mocha-plugin');
const chaiExclude = require('chai-exclude');
const sinon = require('sinon');
mochaPlugin.chai.use(chaiExclude);
const expect = mochaPlugin.chai.expect;
const assert = mochaPlugin.chai.assert;
let createHandler = mochaPlugin.getWrapper('postStory', '/../../functions/create/create.js', 'handler');
const { constants } = require('core/index');
const localConstants = require('../utils/constants');
const AWS = require('aws-sdk');
const AWSMock = require('aws-sdk-mock');
describe('create', () => {
let dynamoSpy = sinon.spy();
before((done) => { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 FilterExpression 从 DynamoDb 获取条目列表。如果至少有一个语句为真,我想返回值。但由于某种原因,看起来 AND 是一个默认的条件运算符,而我的结果是空的。如何在NodeJS中将默认条件操作更改为OR?
params = {
TableName: '......',
IndexName : 'user_id-index',
KeyConditionExpression: 'user_id = :user_id',
FilterExpression: 'contains (email, :key) OR contains (name, :key)',
ExpressionAttributeValues: {
":user_id": userId,
":key": item_to_search
}
};
Run Code Online (Sandbox Code Playgroud)