这是我的课堂问题之一.
我能够用if-else创建我自己的Prolog程序,但我被告知我的程序并不是完全声明的,因为它是Prolog中最基本的原则之一.
这是我的代码
%start with :- go.
is_spicy :-
write('Do you want spicy? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("Curry"); recommend("Kurma") ).
is_fry :-
write('Do you want fry food? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("StirFry"); recommend("Chicken") ).
is_chili :-
write('Do you want chili? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("Sambal"); recommend("Singgang") ).
recommend(Food) :- write('We recommend you '), write(Food).
go :-
write('Which food type do you prefer? (indian, chinese, malay): '),
read(FoodType),
(
FoodType == indian …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个受密码保护的屏幕.屏幕将使用4个数字输入作为密码.
我这样做的方法是创建一个TextInput组件,并在我的主屏幕中调用它4次.
我遇到的问题是当我键入前一个TextInput的值时,TextInputs不会关注下一个.
我正在为所有PasscodeTextInput组件使用refs(我已被告知这是一种遗留方法,但我不知道其他任何方式,唉).
试过这个方法(没有创建我自己的组件),也没有运气. 方法
index.ios.js
import React, { Component } from 'react';
import { AppRegistry, TextInput, View, Text } from 'react-native';
import { PasscodeTextInput } from './common';
export default class ProgressBar extends Component {
render() {
const { centerEverything, container, passcodeContainer, textInputStyle} = styles;
return (
<View style={[centerEverything, container]}>
<View style={[passcodeContainer]}>
<PasscodeTextInput
autoFocus={true}
ref="passcode1"
onSubmitEditing={(event) => { this.refs.passcode2.focus() }} />
<PasscodeTextInput
ref="passcode2"
onSubmitEditing={(event) => { this.refs.passcode3.focus() }} />
<PasscodeTextInput
ref="passcode3"
onSubmitEditing={(event) => { this.refs.passcode4.focus() }}/>
<PasscodeTextInput
ref="passcode4" /> …Run Code Online (Sandbox Code Playgroud) 我得到Object.freeze只能在对象上调用(仅在Android上)。
经过深入研究,我发现这是因为我在不同的文件夹中引用了所有样式,而Android对此并不满意。
我的文件夹结构
src
App.js
Router.js(具有样式)
如您所见,模拟器开始抱怨
Router.js: 9
Run Code Online (Sandbox Code Playgroud)
对应于
import styles from './styles'; // Line 9 in Router.js
Run Code Online (Sandbox Code Playgroud)
长话短说,只有当我在要进行样式设置的文件中创建本地StyleSheet变量时,问题才会消失,这很烦人。
有人遇到过吗?我找不到解决方案:(
这是我的样式索引,也许某些方法未定义并且我不知道
计算尺寸
Router.js: 9
Run Code Online (Sandbox Code Playgroud)
index.js
import styles from './styles'; // Line 9 in Router.js
Run Code Online (Sandbox Code Playgroud)
所以我在两个视图控制器之间执行segue时遇到了问题.
我们打电话给2个视图控制器
答:LoginViewController
B:ViewController
在BI中有一个"Log Out"按钮(它是一个左栏按钮项),当它点击它时触发一个函数,就像这样,并调用dismissViewController并返回A.
@IBAction func logOutButton(sender: AnyObject) {
let actionController = UIAlertController(title: "Log out", message: "Are you sure you want to log out?", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default){UIAlertAction in
self.prefs.setInteger(0, forKey: "ISLOGGEDIN")
self.prefs.setInteger(0, forKey: "PERMISSIONTOLOADDATA")
self.prefs.synchronize()
print("User logged out")
socket.disconnect()
self.dismissViewControllerAnimated(true, completion: nil)
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default){UIAlertAction in
print("Test: Log out action cancelled")
}
actionController.addAction(okAction)
actionController.addAction(cancelAction)
self.presentViewController(actionController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
这里没有错,但是当我在A的文本字段中输入我的ID并单击Login按钮时,它会触发这样的错误:
2016-02-02 17:33:12.879 iCare[3852:190330] <UIView: …Run Code Online (Sandbox Code Playgroud) 我正在研究React Native应用程序,我正在尝试使用名为react-native-socketio的模块.
为了继续使用该应用程序,我需要在Xcode中桥接目标C头,但缺少相关部分.
我也注意到Xcode中也缺少Swift编译器 - 代码生成部分.
为什么?
首先,我们都知道找到一个数组的索引很容易,但我找到了一个包含多个结构的数组中的项目索引.
这是我的班级:
class Patient{
private var id: Int
private var name: String
private var gender: String
private var mileage: Double
//global variable
var globalPatientID:Int{
return id
}
var globalPatientName:String{
return name
}
var globalPatientGender:String{
return gender
}
var globalPatientMileAge:Double{
return mileage
}
init(id:Int, name:String, gender:String, mileage:Double){
self.id = id
self.name = name
self.gender = gender
self.mileage = mileage
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的阵列:
let AppUserID = prefs.objectForKey("AppUserID")
for var i=0; i<nou; ++i{
numberOfUsersExisting = nou
if (AppUserID as? String == json[0][i]["App_ID"].stringValue){
print("Assigning …Run Code Online (Sandbox Code Playgroud) ios ×3
react-native ×3
swift ×3
javascript ×2
xcode ×2
android ×1
arrays ×1
css ×1
declarative ×1
facebook ×1
objective-c ×1
prolog ×1
reactjs ×1
segue ×1
swift2 ×1
textinput ×1