小编SSt*_*eve的帖子

从Swift中删除字符串中第一个字符最简洁的方法是什么?

我想从字符串中删除第一个字符.到目前为止,我提出的最简洁的事情是:

display.text = display.text!.substringFromIndex(advance(display.text!.startIndex, 1))
Run Code Online (Sandbox Code Playgroud)

我知道我们不能使用IntUnicode 来索引字符串,但是这个解决方案看起来非常冗长.还有另一种我忽视的方式吗?

string swift

107
推荐指数
7
解决办法
8万
查看次数

如何隐藏UIAlertController中的标题/消息帧?

当使用a时UIAlertController,如果我想要呈现UIActionSheet空标题和空消息,则预期放置标题和/或消息的帧仍然存在.

如何更改此设置以便我只显示以下ActionSheet内容:

设置
退出
取消?

谢谢!

UIAlertController示例

ios swift uialertcontroller

46
推荐指数
3
解决办法
1万
查看次数

如何在iPhone UILabel中设置字距调整

我正在开发一个iPhone应用程序,我想在UILabel中设置字距.我写的代码(可能在附近kCTKernAttributeName)似乎是错误的.我该如何解决这个问题呢?

NSMutableAttributedString *attStr;   
NSString *str = @"aaaaaaa";    
CFStringRef kern = kCTKernAttributeName;        
NSNumber *num = [NSNumber numberWithFloat: 2.0f];    
NSDictionary *attributesDict = [NSDictionary dictionaryWithObject:num 
forKey:(NSString*)kern];        
[attStr initWithString:str attributes:attributesDict];      
CGRect frame1 = CGRectMake(0, 0, 100, 40);    
UILabel *label1 = [[UILabel alloc] initWithFrame:frame1];    
label1.text = attStr    
[self.view addSubview:label1];
Run Code Online (Sandbox Code Playgroud)

cocoa-touch uilabel kerning ios

32
推荐指数
6
解决办法
3万
查看次数

如何在Gnuplot中启用pngcairo终端

我想将一个数字绘制成PNG格式(避免使用转换),但是我的Gnuplot发行版不提供PNGCAIRO终端.我该如何安装/启用它?我在Mac OS X 10.6上使用Gnuplot 4.4,patchlevel 2.

[me]machine @ test $ gnuplot

G N U P L O T
Version 4.4 patchlevel 2
last modified Wed Sep 22 12:10:34 PDT 2010
System: Darwin 10.8.0

Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others

gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help seeking-assistance"
immediate help:   type "help"
plot window:      hit 'h'

Terminal type set to 'x11'
gnuplot> set terminal pngcairo
                      ^
     unknown or ambiguous terminal type; type just …
Run Code Online (Sandbox Code Playgroud)

terminal png gnuplot

15
推荐指数
3
解决办法
2万
查看次数

应用程序退出时无法恢复亮度

我的应用程序(音乐家的节拍器应用程序)中有一项功能可以调暗屏幕以节省电池寿命.要设置亮度,我正在使用:

[UIScreen mainScreen].brightness = 0.1;
Run Code Online (Sandbox Code Playgroud)

我在viewDidLoad(...)中启动app保存原始亮度并将其保存到我的用户默认值.

在应用程序中更改视图时,我从用户默认值中检索原始亮度并通过调用恢复:

[UIScreen mainScreen].brightness = originalBrightness;
Run Code Online (Sandbox Code Playgroud)

这很好用.我有NSLog(...)消息显示原始值等...所以机制工作.

我遇到的问题是如何在按下主页按钮时恢复应用程序退出时的原始亮度.

我已经为我的应用程序委托方法添加了类似的代码:

applicationWillResignActive(...)
applicationDidEnterBackground(...)
applicationWillTerminate(...)
Run Code Online (Sandbox Code Playgroud)

它们每个都有一个方法调用,用于在视图中设置屏幕亮度,类似的NSLog(...)显示检索到的原始亮度...并且它都是正确的.我也已调试并且正在调用设置亮度...但是应用程序退出,设备屏幕仍处于较低的调暗级别.

最后,如果单击顶部的"锁定"按钮,然后按"主页"按钮将其唤醒...亮度正确.

我的怀疑是,当应用程序退出时我设置亮度的调用触发的任何操作或事件都没有通过,可能是由于状态无效或类似.

此外,我的应用程序设置为不在后台运行,在info.plist中设置为:

Application does not run in background     YES
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

谢谢!

iphone brightness mainwindow uiscreen

12
推荐指数
1
解决办法
1561
查看次数

VS Code Code Runner不适用于virtualenvs

我无法使用Code Runner扩展来与virtualenvs一起工作.每当我尝试运行导入仅在virtualenv中安装但不在全局Python安装中的库的代码时,我会收到导入错误.在终端中运行完全相同的代码.

我在Windows 10上安装了Python 3.6.5.

我得到的确切错误是:

ModuleNotFoundError: No module named 'bs4'
Run Code Online (Sandbox Code Playgroud)

python virtualenv python-3.x visual-studio-code vscode-code-runner

12
推荐指数
4
解决办法
2563
查看次数

为什么Console.WriteLine不能在Visual Studio代码中工作?

我在Visual Studio Code上安装了scriptcs和coderunner.当我运行一个简单的程序,包括Console.WriteLine("Test")我没有看到任何输出.该程序似乎成功运行并退出代码0.

有什么建议?

以下是所有人都感兴趣的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Test");
    }
}
Run Code Online (Sandbox Code Playgroud)

c# scriptcs visual-studio-code vscode-code-runner

10
推荐指数
2
解决办法
5503
查看次数

如何在Cocoa打印对话框中获取"页面属性"选项?

我正在编写的程序在OS X 10.5 Leopard下运行.我的目标是其基本SDK和部署目标都设置为Mac OS X 10.5.当我启动打印时,我的打印对话框不显示"页面属性"选项,用户可以在其中选择页面大小和方向.

没有页面属性

在Leopard下运行的其他程序会显示此选项:

是页面属性

这是启动打印的代码:

-(void)print {
    NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
    TemperaturePressurePrintView *printView = [[TemperaturePressurePrintView alloc] initWithFrequencies:frequencies];
    if (printView) {
        [[NSPrintOperation printOperationWithView:printView printInfo:printInfo] runOperation];
        [printView release];
    }
}
Run Code Online (Sandbox Code Playgroud)

要使页面属性显示在我的打印对话框中,我需要做什么?

printing cocoa nsprintoperation

8
推荐指数
1
解决办法
1559
查看次数

核心图中的两个y轴,具有不同的轴刻度

我正在编写一个应用程序,其中我有两个y轴和一个x轴的图形.左侧y轴的范围从0到20所以有20个majorTick轴.右y轴的范围从0到10,所以我想要左y轴标记为每个替代majorTickAxis.

这是我的代码片段

//code
   CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)self.graph.defaultPlotSpace;
float xmax=10.0;
float xmin=0.0;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(xmin)      length:CPTDecimalFromFloat(xmax-xmin)];
float ymax=20.0;
float ymin=0.0;
float ymax2=10.0;
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(ymin) length:CPTDecimalFromFloat(ymax-ymin)];



// Grid line styles
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 0.75;
majorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.75];

CPTMutableLineStyle *minorGridLineStyle = [CPTMutableLineStyle lineStyle];
minorGridLineStyle.lineWidth = 0.25;
minorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.1];

CPTMutableLineStyle *redLineStyle = [CPTMutableLineStyle lineStyle];
redLineStyle.lineWidth = 2.0;
redLineStyle.lineColor = [[CPTColor redColor] colorWithAlphaComponent:0.5];                         

CPTMutableLineStyle *greenLineStyle = [CPTMutableLineStyle lineStyle];
greenLineStyle.lineWidth = 2.0;
greenLineStyle.lineColor …
Run Code Online (Sandbox Code Playgroud)

xcode core-plot

8
推荐指数
1
解决办法
5528
查看次数

出现错误:/ bin / sh脚本:找不到命令

我正在使用Visual Studio Code for Mac,运行扩展名CodeRunner。我有一个简单的程序:

using System;
namespace HelloWorldApplication {
class HelloWorld {
   static void Main(string[] args) {
      Console.WriteLine("hellowol");
   }
 }
}
Run Code Online (Sandbox Code Playgroud)

使用右上角的播放按钮运行它时,出现以下错误:

/bin/sh scriptcs: command not found
Run Code Online (Sandbox Code Playgroud)

然后

[Done] exited with code=127 in 0.008 seconds
Run Code Online (Sandbox Code Playgroud)

程序未显示所需的输出。

编辑:非常感谢@VonC。他的方法行得通。 任何人的专业提示:使用安装脚本

brew install scriptcs
Run Code Online (Sandbox Code Playgroud)

c# scriptcs visual-studio-code vscode-code-runner

8
推荐指数
1
解决办法
4872
查看次数