小编bas*_*nce的帖子

Swift中的viewWillLayoutSubviews

我正试图转换SKScene * scene = [GameScene sceneWithSize:skView.bounds.size];成swift但我得到了错误

'sceneWithSize'不可用:使用对象构造'SKScene(size :)'.

我正在使用viewWillLayoutSubviews并切割它,viewDidLoad()因为它没有为我选择的设备的屏幕尺寸提供正确的尺寸.它实际上让我怀疑为什么viewDidLoad()存在?

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews();
    let skView = self.view as SKView;
    if skView.scene != nil {
        skView.showsFPS = true;
        skView.showsNodeCount = true;
        skView.showsPhysics = true;
        // Create and configure the scene

        let scene:SKScene = GameScene.sceneWithSize(skView.bounds.size); // ERROR MESSAGE!
        //    Objective-C code in next 2 lines
        //    SKScene * scene = [GameScene sceneWithSize:skView.bounds.size];
        //    scene.scaleMode = SKSceneScaleModeAspectFill;

        // Present Scene
        skView.presentScene(scene)
    }
}
Run Code Online (Sandbox Code Playgroud)

swift

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

如何使用Slack Reminder API将Slack Reminder设置为通道?

当前的Slack API for Reminders允许开发人员为特定人员创建提醒。此提醒是通过Slackbot直接发送给他们的;但是,我希望将提醒发布在公共频道上。提醒API未指定频道参数,因此我不确定如何使用其API完成此操作。我已经发布了当前代码,以为下面的特定用户创建提醒,以供参考。

提醒用户

var payload = {
    "token": settings.slackToken,
    "text": text,
    "time": time,
    "user": user
};

var options = {
    'method': 'post',
    'payload': payload
};

var response = UrlFetchApp.fetch(settings.slackRemindersURL, options);
Run Code Online (Sandbox Code Playgroud)

javascript slack-api

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

如何使用AFNetworking AFHTTPRequestOperationManager显示ProgressBar

当我从网址下载JSON时,我正在尝试显示进度条.JSON正在正确下载,但我不知道如何显示进度条.我尝试过使用UIProgressView但它没有显示在屏幕上.任何建议,将不胜感激.

CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;

CGRect rect = CGRectMake(width/2, height/2, width/5, height/5);
UIProgressView *myProgressView = [[UIProgressView alloc]initWithFrame:rect];
myProgressView.progressViewStyle = UIProgressViewStyleBar;
[self.view addSubview:myProgressView];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];    
[manager GET:@"https:urlWithJson" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
      [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead)
       {
           myProgressView.progress = (float)totalBytesRead / totalBytesExpectedToRead;
       }];
      [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
          NSLog(@"operation Completed");
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"ERROR");
      }];

      [operation start];
  } failure:^(AFHTTPRequestOperation *operation, …
Run Code Online (Sandbox Code Playgroud)

objective-c uiprogressview ios afnetworking-2

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

Facebook SDK for iOS Access Token Issue

我试图在我的iOS swift应用程序中使用Facebook来获取一些基本的用户信息.我使用Cocoapods来安装Facebook依赖项.我使用以下链接更新了我的info.plist.

https://developers.facebook.com/docs/ios/ios9 https://developers.facebook.com/quickstarts/115956755431487/?platform=ios

每当我尝试通过Facebook登录时,我都会收到以下编译器错误:

-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
Error: Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body =     {
    error =         {
        code = 2500;
        "fbtrace_id" = F1CmQQhd4pA;
        message = "An active access token must be used to query information about the current user.";
        type = OAuthException;
    };
};
code = 400; …
Run Code Online (Sandbox Code Playgroud)

facebook ios swift

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