小编Ale*_*dro的帖子

缺少[在开始消息发送表达式

这段代码有什么问题:

NSError *error = nil;

[SFHFKeychainUtils deleteItemForUsername:@"<span class="Apple-style-span" style="font-family: Times; font-size: small;">IAPNoob01</span>" andServiceName:kStoredData error:&error];
Run Code Online (Sandbox Code Playgroud)

错误是:

问题:缺少[在启动消息发送表达式

xcode ios

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

延迟动画UIImageView

我用这种方式动画UIImageView:

int timerAnimation = 0.0f;

for (UIImageView* img in imageArray) {

timerAnimation = timerAnimation + 1.0f;

[UIView animateWithDuration:1.0f
                      delay:timerAnimation
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     img.frame = CGRectMake(20, img.frame.origin.y, 710, 60);
                 }
                 completion:NULL];
Run Code Online (Sandbox Code Playgroud)

我想减少延迟时间,但我注意到如果我把任何值都低于1.0,

例如

timerAnimation + 0.5f;
Run Code Online (Sandbox Code Playgroud)

然后所有对象在保存时移动,就像没有延迟一样.为什么是这样?

cocoa-touch ios

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

exc_bad_access(code = 1,address = 0x2012

我收到此错误:

exc_bad_access (code=1, address=0x2012 
Run Code Online (Sandbox Code Playgroud)

当我尝试以这种方式从单身人士那里收到一个值时:

Draggable* sharedSingleton = [Draggable sharedManagerDraggable];
NSLog(@"%@", sharedSingleton.namePassedToDraggable);
Run Code Online (Sandbox Code Playgroud)

上面的代码放在UIImageView类型的Draggable.m中,它还具有:

+ (Draggable *)sharedManagerDraggable
{
static Draggable *sharedManagerDraggable = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    sharedManagerDraggable = [[Draggable alloc] init];
});
return sharedManagerDraggable;
}
Run Code Online (Sandbox Code Playgroud)

我以这种方式为namePassedToDraggable赋值(从视图controller.m):

#import Draggable.h

Draggable* sharedSingleton = [Draggable sharedManagerDraggable];
    sharedSingleton.namePassedToDraggable = txt.text;
        NSLog(@"%@", sharedSingleton.namePassedToDraggable);
    dragger.tag = img.tag;
Run Code Online (Sandbox Code Playgroud)

在Draggable.h我有:

+ (Draggable *) sharedManagerDraggable;

@property (nonatomic, assign) NSString* namePassedToDraggable;
Run Code Online (Sandbox Code Playgroud)

为什么我会收到导致应用崩溃的错误?我在其他viewcontorllers中使用相同的方法,它工作得很好!

cocoa-touch objective-c ios

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

使UIImageView IOS变暗

我试图做的是使UIImageView更暗,以便在图像顶部显示按钮和视图.我想给它在用户使用Facebook分享的ios6时给出的效果.它背后的所有内容都变得更暗,但它是可见的.我试过用:

    UIImage *maskedImage = [self darkenImage:image toLevel:0.5];

- (UIImage *)darkenImage:(UIImage *)image toLevel:(CGFloat)level
{
// Create a temporary view to act as a darkening layer
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
UIView *tempView = [[UIView alloc] initWithFrame:frame];
tempView.backgroundColor = [UIColor blackColor];
tempView.alpha = level;

// Draw the image into a new graphics context
UIGraphicsBeginImageContext(frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[image drawInRect:frame];

// Flip the context vertically so we can draw the dark layer via a mask that
// aligns with the …
Run Code Online (Sandbox Code Playgroud)

xcode ios

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

CGContextSetRGBFillColor参数太少

我试图以这种方式为我的CGContextSetRGBFillColor设置一个颜色:

- (void) drawArrowWithContext:(CGContextRef)context atPoint:(CGPoint)startPoint withSize: (CGSize)size lineWidth:(float)width arrowHeight:(float)aheight andColor:(UIColor *)color
{   
CGContextSetRGBFillColor (context,color,color,color,1);
CGContextSetRGBStrokeColor (context, color.CGColor);

....
}
Run Code Online (Sandbox Code Playgroud)

...但我在两种情况下都得到错误"参数太少,应该是5,是2".我该如何解决这个问题?

xcode ios

0
推荐指数
1
解决办法
886
查看次数

检测UI按钮是否重叠

我的视图中有两个UIButton,我试图检测两者是否重叠,以便做:

如果(重叠)移动第二个按钮

我试过这个:

if (BluetoothDeviceButton.X1 < btn.X2 && BluetoothDeviceButton.X2 > btn.X1 &&
    BluetoothDeviceButton.Y1 < btn.Y2 && BluetoothDeviceButton.Y2 > btn.Y1){

 }
Run Code Online (Sandbox Code Playgroud)

我不能真正得到我应该放的而不是X1,X2等.我真的不知道这种方法是否会起作用.

ios

0
推荐指数
1
解决办法
332
查看次数

Heroku 从 Javascript 运行 Jar

我正在尝试从 Javascript 文件执行 Jar 文件以获取控制台输出。我已将两个文件推送到 Heroku,但是当我尝试在 js 文件中调用该函数时,出现此错误:

/bin/sh: 1: java: not found exec 错误: 错误: 命令失败: java -jar -Xms1024m MongoConnector-all abaabaa

[31merror[39m: RangeError: 超出最大调用堆栈大小

这是我拥有的代码:

const runCoreSearch = function(searchInputString) {
  const exec = require('child_process').exec;
  //child = exec('/usr/bin/java -jar ~/Applications/Mongo Connector-all.jar' + rakeInputString,
  const child = exec('java -jar -Xms1024m MongoConnector-all ' + searchInputString,
  function (error, stdout, stderr){
...
Run Code Online (Sandbox Code Playgroud)

在他们的网站 ( https://devcenter.heroku.com/articles/deploying-executable-jar-files ) 上说要使用命令“heroku deploy:”,但我不是要部署 Java 项目,只需执行来自 node.js 项目的 jar。有任何想法吗?

javascript java heroku

0
推荐指数
1
解决办法
754
查看次数

带有Integer的NSMutableArray

我有这个可变数组:

myIntegers = [NSMutableArray array];

[myIntegers addObject:[NSNumber numberWithInteger:indexDelete - 1]];

NSLog (@"Array: %@", myIntegers);
Run Code Online (Sandbox Code Playgroud)

如果我执行代码两次,indexDelete首先是1然后是2,我得到这个结果:

Array: (
1
)
Run Code Online (Sandbox Code Playgroud)

然后:

Array: (
2
)
Run Code Online (Sandbox Code Playgroud)

但我想存储这样的数字:

Array: (
1
2
)
Run Code Online (Sandbox Code Playgroud)

为什么不添加,而是替换对象?

xcode objective-c

-1
推荐指数
1
解决办法
123
查看次数

NSMutableArray:获取特定对象

我有一个NSMutableArray.当我使用时NSLog,这是输出:

2012-12-15 17:58:28.849 Splash-it[504:907] (
"Open House New York",
"Boston Athletic Association",
"Autofest Tanzania"
),
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到NSString这些标题中的一个(考虑到标题会改变,我想我需要使用objectAtIndex但我不认为它会在这种情况下起作用)?

例如

NSString = @"Boston Athletic Association"
Run Code Online (Sandbox Code Playgroud)

xcode objective-c nsmutablearray ios

-1
推荐指数
1
解决办法
4195
查看次数

从其他类Swift访问UI对象的属性

我在Swift 2.0中有这个类:

class CharacterSelectionController: UIViewController {
    @IBOutlet weak var scrollView: UIScrollView!
    @IBOutlet weak var scnView: SCNView!

    var characterArray = [CharacterInfo]()
    var scene: CharacterScene!

    override func viewDidLoad() {

        // Set up the SCNView
        scnView.backgroundColor = AppDelegate().lightBlueColor()
        scnView.showsStatistics = false
        scnView.antialiasingMode = SCNAntialiasingMode.Multisampling2X
        scnView.overlaySKScene = SKScene(size: view.bounds.size)
        scnView.playing = false

       // Start playing the scene
      scnView.scene = scene
      scnView.scene!.rootNode.hidden = false
      scnView.play(self)
Run Code Online (Sandbox Code Playgroud)

在AppDelegate和其他类中,我必须将scnView设置为暂停,类似于scnView.pause(self).但是,我似乎无法访问其他类中的视图或自我部分.我尝试用这种方式设置一些结构:

struct GlobalVariables {
    static var globalGameView: SCNView = SCNView()
}
Run Code Online (Sandbox Code Playgroud)

然后设置globalGameView = scnView但它不起作用.我也尝试过:

    var myCustomViewController: CharacterSelectionController = CharacterSelectionController(nibName: nil, …
Run Code Online (Sandbox Code Playgroud)

ios swift

-1
推荐指数
1
解决办法
727
查看次数

提取部分NSString

我有一个像这样的字符串:

<MCPeerID: 0x16e5cf00 DisplayName = Alex's ipad>
Run Code Online (Sandbox Code Playgroud)

我需要从中获取DisplayName,它可以改变长度,所以我不能只剪切最终字符.

如何从此字符串中提取DisplayName属性?

ios

-2
推荐指数
1
解决办法
92
查看次数

将整数传递给方法

我试图将int类型的简单整数传递给void方法,如下所示:

-(void)deleteGroup{
Run Code Online (Sandbox Code Playgroud)

我知道我应该这样做:

[self deleteGroup withInt: 3];
Run Code Online (Sandbox Code Playgroud)

但我似乎无法找出正确的解决方案

objective-c

-5
推荐指数
1
解决办法
139
查看次数