SwiftUI error All In One
SwiftUI error All In One
Instance member xxx cannot be used on type yyy
Instance member 'game' cannot be used on type 'ContentView_Previews'
//
// ContentView.swift
// MemorizeGame
//
// Created by 夏凌晨 on 2020/10/28.
// Copyright 2020 xgqfrms. All rights reserved.
//
// viewModel
import SwiftUI
// some View,返回任意类型的 View, 自动推断 View 类型
// Identifiable
struct ContentView: View {
var viewModel: EmojiMemoryGame
var body: some View {
HStack {
// ForEach(0..<4) { index in
ForEach(viewModel.cards) { card in
// print("index \(index)")
CardView(card: card).onTapGesture {
// self
self.viewModel.choose(card: card)
}
// CardView(isFaceUp: (index % 2 == 0))
}
}
// HStack {
// CardView(isFaceUp: true)
// CardView(isFaceUp: false)
// CardView(isFaceUp: true)
// CardView(isFaceUp: false)
// }
}
}
struct CardView: View {
var card: MemoryGame<String>.Card
// var isFaceUp: Bool
// var isFaceUp: Bool = false
var body: some View {
ZStack {
if card.isFaceUp {
RoundedRectangle(cornerRadius: 10.0).fill(Color.white)
RoundedRectangle(cornerRadius: 10.0).stroke(lineWidth: 3.0)
Text(card.content).font(.largeTitle)
// Text("").font(.largeTitle)
} else {
RoundedRectangle(cornerRadius: 10.0).fill(Color.orange)
}
}.padding()
}
}
// PreviewProvider 仅用于预览,代码在项目中没有实际的意义
struct ContentView_Previews: PreviewProvider {
let game = EmojiMemoryGame()
static var previews: some View {
ContentView(viewModel: game)
}
}
change file name bug
- old MemorizeGame
//
// ContentView.swift
// MemorizeGame
- new MemoryGame
//
// ContentView.swift
// MemoryGame
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
SwiftUI error All In One的更多相关文章
- SwiftUI学习(一)
总览 如果你想要入门 SwiftUI 的使用,那 Apple 这次给出的官方教程绝对给力.这个教程提供了非常详尽的步骤和说明,网页的交互也是一流,是觉得值得看和动手学习的参考. 不过,SwiftUI ...
- 解析SwiftUI布局细节(三)地图的基本操作
前言 前面的几篇文章总结了怎样用 SwiftUI 搭建基本框架时候的一些注意点(和这篇文章在相同的分类里面,有需要了可以点进去看看),这篇文章要总结的东西是用地图数据处理结合来说的,通过这篇文章我们能 ...
- Mediaplayer error (-19,0)
Android MediaPlayer 发生 error (-19,0) 错误解决方法. 引起原因:由于多次实例化MediaPlayer.start() 进行播放操作引起的.由于没有及时释放内存资源导 ...
- 4.Android 打包时出现的Android Export aborted because fatal error were founds [closed]
Android 程序开发完成后,如果要发布到互联网上供别人使用,就需要将自己的程序打包成Android 安装包文件(Android Package,APK),其扩展名为.apk.使用run as 也能 ...
- myeclipse 内存不够用报错PermGen space 和 An internal error has occurred.
最近项目中又增加了新的模块,项目的代码又多了不少.运行的时候总是报如下错误 Exception in thread "http-apr-80-exec-6" java.lang.O ...
- error C4430:missing type specifier 解决错误
错误 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...
- PhpStorm和WAMP配置调试参数,问题描述Error. Interpreter is not specified or invalid. Press “Fix” to edit your project configuration.
PhpStorm和WAMP配置调试参数 问题描述: Error. Interpreter is not specified or invalid. Press “Fix” to edit your p ...
- Visual Studio:error MSB8020(搬运)
状况如下: error MSB8020: The builds tools for v120 (Platform Toolset = 'v120') cannot be found. To build ...
- 转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38
转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38http://space.itpub. ...
随机推荐
- Vue基础之生命周期函数[残缺版]!
Vue基础之生命周期函数[残缺版]! 为什么说是残缺版呢?! 因为有一些周期函数我并没有学到!所以是残缺版! 01 beforeCreate //在实例初始化之后,数据观测 (data observe ...
- HTML Standard系列:Event loop、requestIdleCallback 和 requestAnimationFrame
HTML Standard系列:Event loop.requestIdleCallback 和 requestAnimationFrame - 掘金 https://juejin.im/post/5 ...
- 【Soul网关探秘】http数据同步-Web端处理变更通知
个人知识库 引言 上一篇,梳理http 数据同步策略的变更通知机制,本篇开始探究配置变更通知到达后, soul-web 端的处理响应. 不同数据变更的通知机制应当是一致的,故本篇以 selector ...
- cpdd 坐标:SD
updata on:2021.1.17 闲来无事继续鸽 性别:男 先鸽一会想起来再填/se
- linux下安装 zookeeper-3.4.9并搭建集群环境
本文主要记录作者在实践过程中实现在centos7环境下安装zookeeper并搭建集群的详细步骤,关于zookeeper本文将不做详细介绍,安装步骤详情如下: 前提准备:3台linux服务器(因为zo ...
- 查看Linux用的桌面是GNOME、KDE或者其他(转)
http://superuser.com/questions/96151/how-do-i-check-whether-i-am-using-kde-or-gnome 1) pgrep -l &quo ...
- HTML学习速记
HTML结构导图 先看HTML结构示意图 本文主要讲解HTML当中的一些html标签,css样式,javascript方法 html html的标签有各式各样的数不胜数,但是常用的并不多,总结下我目前 ...
- 一次小模块的使用过程-LC12S无线模块介绍
前言: 最近帮人做了个小设备,使用了无线模块.触摸芯片,主要功能就是把触摸按键的信号无线传到控制继电器输出,MCU是STM8系列的芯片,其中使用过程中调试无线模块LC21S觉得挺好用的,就写了这篇文章 ...
- linux虚拟摄像头vivid配置
总述 最近在看摄像头驱动,需要配置虚拟摄像头的驱动,但是教程里面是linux2.6内核的,实际电脑的是Ubuntu16,内核是linux4.15版本,从2.6到4.15内核好多文件发生了变化,所 ...
- A - A Supermarket (贪心, 并查集)
超市里有n个产品要卖,每个产品都有一个截至时间dx(从开始卖时算起),只有在这个截至时间之前才能卖出并且获得率润dy. 有多个产品,所有可以有不同的卖出顺序,每卖一个产品要占用1个单位的时间,问最多能 ...