我创建NSMutableAttributedString的子类,在我的项目做一个字符串,不断改变每个字符在初始化数组给出的一种颜色之一,但是当我尝试调用init方法,我得到sigabrt的initWithString:方法.
#import <Foundation/Foundation.h>
@interface RainbowString : NSMutableAttributedString
@property (nonatomic) NSArray* colors;
@property (nonatomic) NSTimeInterval duration;
@property (nonatomic) NSTimer* timer;
- (id)initStringWithColors:(NSArray*)colors withString:(NSString*)string;
- (id)initStringWithColors:(NSArray*)colors withCycleDuration:(NSTimeInterval)duration withString:(NSString*)string;
- (void)stop;
- (void)start:(NSTimeInterval)duration;
@end
Run Code Online (Sandbox Code Playgroud)
- (id)initStringWithColors:(NSArray *)colors withString:(NSString *)string
{
self = [super initWithString:string];
if(self)
{
[self setColors:colors];
[self cycle];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
即使我只是打电话[[RainbowString alloc] initWithString:@"Hello"];,我也会得到同样的错误:
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [RainbowString initWithString:]:无法识别的选择器发送到实例0x166778c0'
好吧,只是为了测试这个,我创建了一个NSMutableAttributedString的测试子类,绝对没有内容.我刚刚创建了子类并保持原样.
#import <Foundation/Foundation.h>
@interface Test : NSMutableAttributedString
@end
Run Code Online (Sandbox Code Playgroud)
我跑了:
[[NSMutableAttributedString alloc] …Run Code Online (Sandbox Code Playgroud) 问题很简单.是否有任何"正确"的方式来订购jQuery/CSS选择器的部分?例如,假设我有一个具有以下属性的元素:
<div class="red green blue" id="someDiv" anAttr="something">
Run Code Online (Sandbox Code Playgroud)
为了更好地衡量,我们也会在它被徘徊时瞄准它.
以下选择器之间有什么区别吗?:
div.red.green.blue#someDiv[anAttr='something']:hover
div#someDiv.red.green.blue[anAttr='something']:hover
div.red#someDiv[anAttr='something']:hover.blue.green
div[anAttr='something'].blue:hover#someDiv.red.green
Run Code Online (Sandbox Code Playgroud)
意思是,目标的顺序是否重要,真的吗?或者我可以把它们放在任何 - 我想要的顺序?
根据这个JSFiddle,他们都在技术上工作.
我有一个JSON对象,我从我的服务器,看起来像这样:
{
"state":"1",
"player1": {
"alias":"Player Name",
"ready":"0"
}
}
Run Code Online (Sandbox Code Playgroud)
我能够获取JSON,将其解析为FJsonObject,并使用此代码序列化检索JSON对象的第一级中的任何数字或字符串:
TSharedPtr<FJsonObject> JsonParsed;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(json);
if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
//Use JsonParsed
Run Code Online (Sandbox Code Playgroud)
这段代码读取字符串:
FString AJSONContainer::getStringWithKey(FString key)
{
return storedJSON->GetStringField(key);
}
Run Code Online (Sandbox Code Playgroud)
AJSONContainer只是一个Actor类,我用它来从Blueprints调用这些函数.
这一切都很好,但是当我尝试从二级读取东西时,事情就不起作用了.
我编写了这段代码来提升下一级别:
TSharedPtr<FJsonObject> nested = storedJSON->GetObjectField(key);
Run Code Online (Sandbox Code Playgroud)
但所有要求获得领域的电话nested都没有.
nested->GetStringField(anotherKey); //Nothing
Run Code Online (Sandbox Code Playgroud)
所以,例如,使用上面的JSON,这个:
TSharedPtr<FJsonObject> nested = storedJSON->GetObjectField("player1");
FString alias = nested->GetStringField("alias");
Run Code Online (Sandbox Code Playgroud)
alias 将它打印到控制台时没有任何价值.
难道我做错了什么?为什么二级JSON不起作用?
我试图通过我专用服务器上的 localhost 连接到我的 mySQL 服务器,但我不断收到错误消息:
Lost connection to MySQL server at 'reading initial communication packet', system error: 110
Run Code Online (Sandbox Code Playgroud)
代码:
<?php
$link = mysql_connect('localhost', '****', '****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
Run Code Online (Sandbox Code Playgroud)
我还没有配置防火墙,所以所有端口都应该是开放的。我需要做什么?我已经检查了其他几个类似的问题,但没有一个解决了我的问题。我没有远程连接。
更新
好的,我发现了与服务器连接的问题(我连接了两次)。我现在可以连接到服务器,但是当我运行任何查询时,服务器返回 FALSE。我以前用过这个代码,以前也用过,但是现在换了服务器,就不行了。
谢谢,
大卫
好的,所以我已经检查了所有的SO和整个谷歌,我找不到我的代码有什么问题:
- (IBAction)selectFont:(id)sender
{
NSFontManager *fontManager = [NSFontManager sharedFontManager];
[fontManager setDelegate:self];
[fontManager setTarget:self];
NSFontPanel *fontPanel = [fontManager fontPanel:YES];
[fontPanel makeKeyAndOrderFront:sender];
}
- (void)changeFont:(id)sender
{
NSFontManager *fontManager = [NSFontManager sharedFontManager];
font = [fontManager selectedFont];
NSLog(@"%@",[fontManager selectedFont]);
}
Run Code Online (Sandbox Code Playgroud)
弹出字体面板,但是当我选择字体时,控制台将返回(null)字体管理器的选定字体.谁知道我错过了什么?
谢谢
当我尝试构建项目时,我在XCode中遇到了构建语义错误.我有3个NSOperation类设置从互联网下载信息,处理它,并将其发送到父视图控制器,一个实例ViewController.这是工人阶级的代码:
#import <Foundation/Foundation.h>
#import "ViewController.h"
@interface ImageGetter : NSOperation
@property (nonatomic) int sid;
@property (nonatomic, retain) ViewController* pvc;
@end
Run Code Online (Sandbox Code Playgroud)
下面是是一个代码不工作:
#import <Foundation/Foundation.h>
#import "ViewController.h"
@interface CurrentGetter : NSOperation
@property (nonatomic) int sid;
@property (nonatomic, retain) ViewController* pvc;
@end
Run Code Online (Sandbox Code Playgroud)
错误:
ERROR: Unknown type name 'ViewController'; did you mean 'UIViewController'?
Run Code Online (Sandbox Code Playgroud)
为什么我收到此错误?我在两个文件中导入了ViewController.h,只有一个正在工作.
ViewController.h:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "DataGetter.h"
#import "CurrentGetter.h"
#import "AppDelegate.h"
@interface ViewController : UIViewController <UITabBarDelegate>
{
NSTimer* tmr;
}
@property (nonatomic) float …Run Code Online (Sandbox Code Playgroud) 我在为我的一个网站开发 onHover 缩放效果时遇到了这个问题。
当您为 CSS 伪状态设置了过渡持续时间时,设置 zoom 属性将缩放 onHover 元素,但是一旦它达到最大尺寸,它就会缩小到更小的尺寸(但这个尺寸仍然比原始尺寸大) .
但是,当使用x-transform: scale()具有相同过渡的属性时,项目会平滑缩放(并保持其中心坐标,我可能会补充)。
你可以在这个 fiddle 中看到这一点。红色框向右下方生长,但随后跳回较小的尺寸,而蓝色框则平滑地生长并保持完整尺寸。
为什么是这样?
*
{
-webkit-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
-ms-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
transition-duration: 0.3s;
}
box:hover
{
zoom: 1.1;
}
box2:hover
{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
}
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个随机迷宫生成器,将迷宫存储在一个名为的二维数组中grid.然后,这将用于生成真实的3D迷宫,然后用户可以通过该迷宫.
在做了一些研究后,我尝试使用递归分割算法创建这个迷宫生成器,但是由于迷宫格式的性质,这对我来说并不适用.
根据我的理解,递归除法方法不会将墙视为单元格.
例如,我的网格看起来像这样:
a b c d e f g h
1 - - - - - - - -
2 | | | | |
3 | | |
4 | - - | - |
5 | | | |
6 | - | - |
7 x |
8 - - - - - - - -
Run Code Online (Sandbox Code Playgroud)
我试图在这里得到的一点是,我试图创建的网格将表示如下:
w w w w w w w w
w w w w w
w …Run Code Online (Sandbox Code Playgroud) 我注意到hue-rotateCSS 中的滤镜使我的图像变暗。
请参阅https://jsfiddle.net/m4xy3zrn/
请注意,带有滤镜的第二张图像明显比在 Photoshop 中旋转的第三张图像暗。
有办法防止这种情况吗?
再看一遍,这里发生了很多奇怪的事情。黄色似乎几乎全部消失,并且色调彩虹(右上角)中蓝色区域的饱和度大大降低。
我有一个游戏,用户可以创建自定义级别并上传到我的服务器供其他用户玩,我想在用户测试他/她的级别上传到我的服务器之前获取"操作区域"的屏幕截图一个"预览图像".
我知道如何获取整个视图的屏幕截图,但我想将其定义为自定义框架.请考虑以下图像:

我想用红色区域截取屏幕截图,即"动作区域".我能做到吗?
objective-c ×4
css ×3
ios ×3
algorithm ×1
c++ ×1
cocoa ×1
connection ×1
css-filters ×1
iphone ×1
javascript ×1
jquery ×1
json ×1
mysql ×1
nsfontpanel ×1
nsoperation ×1
quartz-core ×1
recursion ×1
screenshot ×1
xcode ×1