我添加UICollectionView了代码.
现在,应用程序崩溃并显示消息:UICollectionView must be initialized with a non-nil layout parameter.
你有什么想法来解决它吗?
CollectionCell是自定义类UICollectionViewCell.
@property (nonatomic, strong) UICollectionView* collectionView;
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView = [[UICollectionView alloc]init];
[self.collectionView registerClass:[CollectionCell class] forCellWithReuseIdentifier:@"cell"];
UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.itemSize = CGSizeMake(100, 100);
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[self.collectionView setCollectionViewLayout:flowLayout];
self.collectionView.frame = CGRectMake(0, 60, 320, 500);
self.collectionView.backgroundColor = [UIColor whiteColor];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.view addSubview:self.eventCollection];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section …Run Code Online (Sandbox Code Playgroud) vagrantup.com说输入vagrant box add hashicorp/precise32,
但是当我输入它时,终端输出错误信息:
This command was not invoked properly. The help for this command is
available below.
Usage: vagrant box add <name> <url> [--provider provider] [-h]
Run Code Online (Sandbox Code Playgroud)
然后,我输入vagrant box add hashicorp/precise32 \ http://files.vagrantup.com/hashicorp/precise32.box,
但下载失败,并显示以下错误消息.
Download failed. Will try another box URL if there is one.
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /Users/XXXX/ http:/files.vagrantup.com/precise32.box
Run Code Online (Sandbox Code Playgroud)
如何安装流浪盒?
有时我想将一个值传递给 @Binding 属性,有时我不想。
struct ParentView: View {
@State var prop = 0.0
var body: some View {
ChildView(prop: $prop) // Error: Cannot convert value of type 'Binding<Double>' to expected argument type 'Binding<Double?>'
ChildView() // sometimes I do not want pass anything
}
}
struct ChildView: View {
@Binding var prop: Double?
init(prop: Binding<Double?> = .constant(nil)) {
_prop = prop
}
var body: some View {
Text("Child View")
}
}
Run Code Online (Sandbox Code Playgroud)
解决方案可能是以下代码。
@State var prop: Double? = 0.0
Run Code Online (Sandbox Code Playgroud)
但是,如果可能的话,我不想将 @State 属性定义为可选类型。
还有其他办法吗?
当我输入时$ vagrant box list,
终端输出:centos64 (virtualbox)
现在我输入$ vagrant init centos64,
终端输出一条错误信息:
"Vagrantfile" already exists in this directory. Remove it before running "vagrant init".
Run Code Online (Sandbox Code Playgroud)
我该如何删除它?
我面临 Cypress 和 Jest 中类型冲突的问题(例如“expect”)。
\n示例.spec.ts
\nexpect(value).toBe(0) // Property \'toBe\' does not exist on type \'Assertion\'.\nRun Code Online (Sandbox Code Playgroud)\n我按照以下方式编辑了tsconfig.json,但没有解决。
\n这是我的tsconfig
{\n "compilerOptions": {\n "target": "ES2018",\n "module": "ESNext",\n "moduleResolution": "Node",\n "resolveJsonModule": true,\n "lib": [\n "ESNext",\n "ESNext.AsyncIterable",\n "DOM"\n ],\n "esModuleInterop": true,\n "allowJs": true,\n "sourceMap": true,\n "strict": true,\n "noEmit": true,\n "experimentalDecorators": true,\n "baseUrl": ".",\n "paths": {\n "~/*": [\n "./*"\n …Run Code Online (Sandbox Code Playgroud) 我想启用UIPanGestureRecognizer的customView时候customView做longPress。
(我想你的时候longPress customView,在customView将切换到“移动模式”,你可以移动customView的拖累。)
但是在这段代码中,只能longPressAction:调用。panAction:没有打电话。
如何修复它以启用它PanAction:?
- (void)viewDidLoad
{
[self.view addSubview:customView];
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
[customView addGestureRecognizer:longPressRecognizer];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
[customView addGestureRecognizer:panRecognizer];
}
- (void)longPressAction:(UILongPressGestureRecognizer *)recognizer
{
if ([recognizer state] == UIGestureRecognizerStateBegan) {
CustomView *customView = (CustomView *)recognizer.view;
customView.panRecongnizerEnabled = YES; //panRecongnizerEnabled is CustomView's property
}
if ([recognizer state] == UIGestureRecognizerStateEnded) {
CustomView *customView = (CustomView …Run Code Online (Sandbox Code Playgroud) 我想用参数View从 Child 调用 Parent 的函数。
下面的代码是错误的。View
struct ContentView: View {
func update(value: Double) {
print("called update: \(value)")
}
var body: some View {
ChildView(onUpdate: update)
}
}
struct ChildView: View {
var onUpdate: (value: Double) -> ()
var body: some View {
VStack {
Text("child view")
Button(action: {
self.onUpdate(value: 3.0)
}) {
Text("onUpdate")
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Vue.js 3.
以下 eslint-plugin-vue 警告似乎是使用 Vue.js 中的规则进行警告 2.
<MyComponent v-model:propName="foo"/>Vue.js 支持这种编写风格 3.
如何使其与 Vue.js 兼容 3 ?
<MyInputComponent
v-model:value="state.value"
/>
// [vue/valid-v-model] 'v-model' directives require no argument. eslint-plugin-vue [7, 9]
Run Code Online (Sandbox Code Playgroud)
.eslintrc.js
module.exports = {
extends: [
'plugin:vue/vue3-recommended',
]
}
Run Code Online (Sandbox Code Playgroud)
包.json
{
"name": "ProjectName",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"typescript": "^4.1.2",
"vue": "^3.0.2"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.0.2",
"eslint-plugin-vue": "^7.1.0",
"vite": "^1.0.0-rc.8"
}
}
Run Code Online (Sandbox Code Playgroud) 我想提出settingView的myView显示和动画消失.
我打电话-showSettingView
if (!self.settingView):动画正常工作.
但是,else if (self.myView):settingView没有动画就消失了.
如何修复它以使settingView动画消失?
@property (nonatomic, strong) UIView *myView;
@property (nonatomic, strong) UIView *settingView;
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem* settingButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showSettingView)];
self.navigationItem.rightBarButtonItem = settingButton;
}
- (void)showSettingView
{
self.myView = [[UIView alloc]initWithFrame:CGRectMake(0, 568, 320, 480)];
self.myView.opaque = NO;
self.myView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.0f];
[self.view addSubview:self.myView];
if (!self.settingView) {
self.settingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
self.settingView.backgroundColor = [UIColor blackColor]; …Run Code Online (Sandbox Code Playgroud) 我命名为PNG 58×58图像,myIcon@2x.png并将其设置为应用程序图标。
通过模拟器构建时,该应用正确运行。
但是,在实际计算机上,应用程序会输出错误
并显示消息,Failed to write PNG data for the app icon set from "AppIcon appiconse.../test.app/AppIcon29×29@2x.png
为什么会发生此类错误?
ios ×4
objective-c ×2
swiftui ×2
vagrant ×2
cypress ×1
eslint ×1
icons ×1
jestjs ×1
swift ×1
typescript ×1
virtualbox ×1
vue.js ×1
vuejs3 ×1
xcode ×1