在要在iPhone上显示的网页上,当用户点击字段而不是qwerty键盘时,是否有办法让数字键盘出现?
这家伙说这是怎么做的,但从2.0开始,这个"功能"被禁用了.
我猜这里有一些花哨的javascript来解决这个限制?
所以我有几个代表各种单位系统的枚举:
enum MassUnit:Double{
case Pound = 453.59237, Ounce = 28.349523125, Gram = 1.0, Kilogram = 1000.0;
}
enum VolumeUnit:Double{
case Teaspoon = 1, Tablespoon = 3, Cup = 48, Pint = 96, Quart = 192, Gallon = 768, Liter = 202.884136211, Milliliter = 0.202884136211
}
enum TimeUnit:Double{
case Second = 1, Minute = 60, Hour = 3600, Day = 86400, Week = 604800, Year = 31536000
}
Run Code Online (Sandbox Code Playgroud)
我想做的是能够从一个单位转换到另一个单位,例如从一年到几秒.为此,我确保我的枚举的原始值对应于转换乘数,例如1 Min = 60秒.因此,给定某个单位的x量,转换就是简单的
x * rawValue1 / rawValue2 // rawValue2 = rawValue …
Run Code Online (Sandbox Code Playgroud) 在Xcode 9.2中,对于我的iOS应用程序,我有一个用于运行UI测试套件的Scheme.在此方案中,在"测试"选项卡下,我定义了环境变量和参数.当我的测试运行时,我的应用程序代码无法使用这些变量.
但是,我能够以编程方式在测试代码中设置参数和launchEnvironment,并且当应用程序在测试下运行时,它们可供应用程序使用.
我还在"运行"选项卡中设置了环境变量和参数,当我仅在模拟器中运行应用程序时,这些变量和参数可用.当我运行我的UI测试时,它们不可用,无论我是否有"使用运行操作的参数和环境变量"切换.
要查看指定参数和ENV瓦尔的价值观,我有一个断点,在我的设置applicationDidFinishLaunching
,我po ProcessInfo.processInfo.environment
和po ProcessInfo.processInfo.arguments
.
我在这里设置错误吗?
我正在尝试创建一个简单的倒数计时器,以便当玩家进入我的游戏时,计时器从60开始下降到0.这看起来很简单,但我对如何写这个感到困惑.
到目前为止,我在GameController.m中创建了一个方法,如下所示:
-(int)countDownTimer:(NSTimer *)timer {
[NSTimer scheduledTimerWithTimeInterval:-1
invocation:NULL
repeats:YES];
reduceCountdown = -1;
int countdown = [[timer userInfo] reduceCountdown];
if (countdown <= 0) {
[timer invalidate];
}
return time;
}
Run Code Online (Sandbox Code Playgroud)
在游戏开始时,我将整数Time初始化为60.然后在ViewController中设置标签.但是在我编译代码的那一刻,它只是将标签显示在60并且根本没有减少.
任何帮助将不胜感激 - 我是Objective-C的新手.
编辑
在一些帮助下,我现在将代码分成两个单独的方法.代码现在看起来像这样:
-(void)countDown:(NSTimer *)timer {
if (--time == 0) {
[timer invalidate];
NSLog(@"It's working!!!");
}
}
-(void)countDownTimer:(NSTimer *)timer {
NSLog(@"Hello");
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(countDown:)
userInfo:nil
repeats:YES];
}
Run Code Online (Sandbox Code Playgroud)
但是,代码仍然无法正常运行,当我从View Controller调用方法[game countDownTimer]时,它会断言:"无法识别的选择器发送到实例".任何人都可以解释这里有什么问题吗?
作为部署过程的一部分,我需要将(大)s3存储桶复制到另一个s3存储桶.是否正在运行aws s3 sync s3://mybucket s3://mybucket2
将mybucket中的文件复制到运行此命令的本地计算机?或者文件是否保留在服务器端?
在我的 iOS 应用程序中,我从 s3 下载游戏资源。我的艺术家更新了一项资产,我们立即开始看到新资产崩溃。
这是处理它们的代码:
+ (UIImage *)imageAtPath:(NSString *)imagePath scaledToSize:(CGSize)size
{
// Create the image source (from path)
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef) [NSURL fileURLWithPath:imagePath], NULL);
NSParameterAssert(imageSource);
// Get the image dimensions (without loading the image into memory)
CGFloat width = 512.0f, height = 384.0f;
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
NSParameterAssert(imageProperties);
if (imageProperties) {
CFNumberRef widthNumRef = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
if (widthNumRef != NULL) {
CFNumberGetValue(widthNumRef, kCFNumberCGFloatType, &width);
}
CFNumberRef heightNumRef = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
if (heightNumRef != NULL) { …
Run Code Online (Sandbox Code Playgroud) 我有一个目录,其中包含约 8000 个以下形式的文件
output/Manuscript_00750_AnimalGiants-compact.json
output/Manuscript_00750_AnimalGiants-expanded.json
output/Manuscript_00750_AnimalGiants.json
output/Manuscript_00752_AnimalGiants-compact.json
output/Manuscript_00752_AnimalGiants-expanded.json
output/Manuscript_00752_AnimalGiants.json
output/Unit_TZH_12345_Foo-compact.json
output/Unit_TZH_12345_Foo-expanded.json
output/Unit_TZH_12345_Foo.json
Run Code Online (Sandbox Code Playgroud)
我需要想出一个正则表达式来使用该find
工具来仅选择 Manuscript-compact 的:
output/Manuscript_00750_AnimalGiants-compact.json
output/Manuscript_00752_AnimalGiants-compact.json
Run Code Online (Sandbox Code Playgroud)
提出正则表达式是容易的部分,但进行find
合作是困难的部分。
这是我的正则表达式:
/Manuscript[0-9_a-zA-Z]+-compact\.json/
Run Code Online (Sandbox Code Playgroud)
以下是我尝试过的一些命令;全部产生零结果。cwd 是上面的目录output/
:
find output -regex "Manuscript[0-9_a-zA-Z]+-compact\.json"
find output -regex "\./output/Manuscript[0-9_a-zA-Z]+-compact\.json/"
find output -regex ".*\Manuscript[0-9_a-zA-Z]+-compact.*\json"
Run Code Online (Sandbox Code Playgroud)
但这个命令确实产生了结果 - 它选择了所有以“Manuscript”开头的文件,这显然太宽泛了:
find output -regex ".*\Manuscript.*\json"
Run Code Online (Sandbox Code Playgroud)
这里正确的正则表达式格式是什么find
?