小编Lau*_*fan的帖子

如何在另一个框架内添加框架(Umbrella Framework)

我使用以下教程构建了一个框架.

我也有这个框架.

我正在尝试在我的内部实现第二个框架,从我在Apple文档中读到的结果框架被称为"伞框架".

我在框架中使用拖放添加了第二个框架,并验证它是否在"Link Binary With Libraries"中.

在我尝试在我的框架的一个类中进行下一次导入之后:

#import <CrashReporter/CrashReporter.h>
Run Code Online (Sandbox Code Playgroud)

我收到错误,因为导入的框架不可见.

另外我看过stackoverflow帖子: 如何在iOS SDK中创建一个伞形框架?

更新

有没有人试图为iOS提取PLCrashReporter类并将其集成到一个项目中?

你可以在这里找到我的尝试.

frameworks ios

43
推荐指数
4
解决办法
3万
查看次数

将子视图控制器添加到当前视图控制器

我试图通过使用下一个代码将代码中的子视图控制器添加到故事板中的当前视图控制器:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init];
lvc = (LogInTutorialViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LogInTutorialViewControllerID"];
[self displayContentController:lvc];

- (void) displayContentController: (LogInTutorialViewController*) content;
{

    //add as childViewController
    [self addChildViewController:content];
    [content didMoveToParentViewController:self];
    [content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    [self.view addSubview:content.view];

}
Run Code Online (Sandbox Code Playgroud)

视图似乎至少在模拟器上显示但在控制台中我得到了很多或错误:

 <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. …
Run Code Online (Sandbox Code Playgroud)

objective-c uinavigationcontroller ios

19
推荐指数
4
解决办法
5万
查看次数

如何使用随机数填充数组?

我试图填充四个元素的数组,正整数小于9.

这是我的代码:

generated_number=Array.new(4)#create empty array of size 4
generated_number.each do |random| #for each position in the array create a random number
  random=rand(10)
end
puts generated_number
Run Code Online (Sandbox Code Playgroud)

我不明白我错过了什么.

ruby

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

当从实时数据库中删除对象时,Firebase功能(用NodeJS编写)从云存储中删除文件

我是NodeJS的新手,我正在尝试为Firebase的Cloud Functions编写下一个方法.

我想要实现的目标:

  1. 当用户从Firebase DB中删除Photo对象时,应该触发该函数;
  2. 代码应从与Photo obj对应的Storage中删除文件对象.

这些是我的Firebase数据库结构:

照片/ {userUID}/{} photoUID

{
"dateCreated":      "2017-07-27T16:40:31.000000Z",
"isProfilePhoto":   true,
"isSafe":           true,
"uid":              "{photoUID}",
"userUID":          "{userUID}"
}
Run Code Online (Sandbox Code Playgroud)

和Firebase存储格式:

照片/ {userUID}/{} photoUID .PNG

我正在使用的NodeJS代码:

    const functions = require('firebase-functions')
    const googleCloudStorage = require('@google-cloud/storage')({keyFilename: 'firebase_admin_sdk.json' })
    const admin = require('firebase-admin')
    const vision = require('@google-cloud/vision')();

    admin.initializeApp(functions.config().firebase)

    exports.sanitizePhoto = functions.database.ref('photos/{userUID}/{photoUID}')
        .onDelete(event => {

            let photoUID = event.data.key
            let userUID = event.data.ref.parent.key

            console.log(`userUID: ${userUID}, photoUID: ${photoUID}`);

            if (typeof photoUID === 'undefined' || typeof userUID === 'undefined') {
                console.error('Error while sanitize …
Run Code Online (Sandbox Code Playgroud)

node.js firebase firebase-realtime-database google-cloud-functions firebase-storage

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

如何在使用NSAttributedString添加照片后从UITextView中检索照片?

我正在使用下一个代码将图像添加到UITextView:

    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(200,200,140,140)];
    textView.font = [UIFont systemFontOfSize:20.0f];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Test  with emoji"];
    NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
    textAttachment.image = [UIImage imageNamed:@"Angel.png"];

    //for the padding inside the textView
    textAttachment.image = [UIImage imageWithCGImage:textAttachment.image.CGImage scale:3.0 orientation:UIImageOrientationUp];
    NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
    [attributedString replaceCharactersInRange:NSMakeRange(5, 1) withAttributedString:attrStringWithImage];
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, attributedString.length)];
    textView.attributedText = attributedString;
    NSLog(@"Text view: %@", textView.attributedText);

    [self.view addSubview:textView];
Run Code Online (Sandbox Code Playgroud)

结果如下:

在此输入图像描述

我感兴趣的是,我怎么知道在文本字段和巫婆位置插入了什么图片?我正在考虑使用attributedText,因为你可以在代码中观察,因为它记录:

Text view: Test {
    NSFont = "<UICTFont: 0x7ff0324f2110> font-family: \".HelveticaNeueInterface-Regular\"; font-weight: normal; font-style: …
Run Code Online (Sandbox Code Playgroud)

objective-c uitextview nsattributedstring ios

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

导出为 USDZ 的 3D 图稿具有不同的颜色

首先我想说,我是 SceneKit 新手,并且在 iOS 上使用 AR 环境。

我有一个 3D 模型对象,一辆货车,作为 Blender 文件(.blend)的一部分 --> 可以在这里找到它。

我将其从 Blender 导出为 .glb 文件 --> 可以在此处找到它。

然后我在 Reality Converter 应用程序中打开 .glb 文件,并将其导出为 .usdz 文件 --> 可以在此处找到它。

问题是当我在 XCode 中预览对象以及将其放置在 AR 中时,对象颜色是错误的。

Blender 对象有问题吗?如果是这样,我应该对其进行什么更改才能正确导出颜色?

在此输入图像描述

在此输入图像描述

maya scenekit swift swiftui realitykit

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

如何使用相同的会话和不同的下载任务下载多个图像

我试图使用相同的会话和不同的下载任务下载多个图像,如问题所示.我可以下载第一张图片而不是第二张图片.在didFinishDownloadingToURL中,我使用if条件来识别downloadTask并且对于某个downloadTask将其设置为某个imageView.

这是我的代码,请耐心等待我:

@interface ViewController ()
{
    NSURLSessionConfiguration *sessionConfiguration;
    NSURLSessionDownloadTask *firstDownloadTask;
    NSURLSessionDownloadTask *secondDownloadTask;
    NSURLSession *session;
    UIImageView *firstImageHolder;
    UIImageView *secondImageHolder;
}
@end

- (void)viewDidLoad
{
            NSString *firstDownloadLink = @"http://letiarts.com/letiarts2014/wp-content/uploads/2014/04/icon_game.png";
            sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
            session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:nil];
            firstImageHolder = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 45, 45)];
            [_viewImages addSubview: firstImageHolder];
            firstDownloadTask = [session downloadTaskWithURL:[NSURL URLWithString:firstDownloadLink]];
            [firstDownloadTask resume];

            //2
            NSString *secondDownloadLink = @"http://downloads.bbc.co.uk/skillswise/images/promo/prefab-maths-game-336x189.jpg";
            secondImageHolder = [[UIImageView alloc] initWithFrame:CGRectMake(50, 0, 45, 45)];
            [_viewImages addSubview: secondImageHolder];
            secondDownloadTask = [session downloadTaskWithURL:[NSURL URLWithString:secondDownloadLink]];
            [secondDownloadTask resume];
}
Run Code Online (Sandbox Code Playgroud)

在didFinishDownloadingToURL中: …

xcode ios nsurlsession

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

Apple Watch OS 2 如何在自定义通知中显示/隐藏操作按钮

我正在构建一个 Apple Watch os 2 应用程序扩展,我需要实现通知。当我阅读苹果文档时,我发现我需要的是一个自定义通知,因此为它构建了 UI,但问题是我必须处理多个通知案例,而不是所有案例都有一个操作按钮,所以我的问题是如何更改操作按钮的名称以及是否可以隐藏它。

我知道可以使用 PushNotificationPayload.apns 文件创建操作按钮,也可以在 apns 文件中设置操作按钮和功能,但是否也可以在代码中执行此操作(隐藏/显示按钮操作并调整它的姓名)。

我在想我可以在 didReceiveRemoteNotification:withCompletion: 中做一些实现吗?

这是一些背景信息:

在此处输入图片说明 在此处输入图片说明

更新 1

再次阅读此苹果文档后,我进行了以下更改:

  1. 实现了另一个通知接口控制器并检查了“具有动态接口”

在此处输入图片说明

  1. 添加了“通知类别名称”

在此处输入图片说明

  1. 创建了“WKUserNotificationInterfaceController”的另一个子类并将其与故事板中的新自定义通知相关联

使用“类别”键和每个自定义类别的正确值(在我的情况下为“Cat1”和“Cat2”),设法测试在通知到达时是否加载了正确的类别。

现在我唯一的问题是:

我如何在本地管理自定义通知按钮?(显示多少按钮,按钮的标题,这样我就不会像 .apns 测试通知那样依赖服务器)

如果这是不可能的,那么我的问题就变成了:

关于显示的操作,来自服务器的通知应该如何(格式)?我是否仍应将操作发送为:

"WatchKit Simulator Actions": [
        {
            "title": "First Button",
            "identifier": "firstButtonAction"
        }
    ]
Run Code Online (Sandbox Code Playgroud)

或者我应该将它们传递给aps密钥:

"alert" : {
     "body" : "Test message",
     "title" : "Optional title",
     "action" : [
        {
           "title" : "First Button",
           "identifier" : "firstButtonAction"
        }
     ]
  }
Run Code Online (Sandbox Code Playgroud)

更新 2

在阅读了将操作按钮添加到通知的文档后,我认为这是我需要做的,同时阅读本教程。但主要区别在于,这样做也会影响我的 iOS …

push-notification ios apple-watch watchkit watchos-2

5
推荐指数
0
解决办法
1097
查看次数

应用完成时,CABasicAnimation会闪烁

我试图将旋转动画按度数应用于a UIImageView并在完成块中保持旋转变换.

我面临的问题是,当执行完成块时,通过从动画的结束状态传递到完成块产生可见的闪烁.

这是我目前使用的代码:

if (futureAngle == currentAngle) {
    return;
}

float rotationAngle;
if (futureAngle < currentAngle) {
    rotationAngle = futureAngle - currentAngle;
}else{
    rotationAngle = futureAngle - currentAngle;
}

float animationDuration = fabs(rotationAngle) / 100;
rotationAngle = GLKMathDegreesToRadians(rotationAngle);

[CATransaction begin];
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.byValue = [NSNumber numberWithFloat:rotationAngle];
rotationAnimation.duration = animationDuration;
rotationAnimation.removedOnCompletion = YES;

[CATransaction setCompletionBlock:^{
    view.transform = CGAffineTransformRotate(view.transform, rotationAngle);
}];

[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)

objective-c cabasicanimation ios catransaction

5
推荐指数
2
解决办法
1016
查看次数

iOS LinkedIn API错误

我正在尝试在我的项目中实现这个LinkedIn库,但是当我尝试呈现LinkedIn屏幕时,我似乎遇到了错误:

授权失败LinkedIn1:错误域= LIALinkedInERROR代码= 1"操作无法完成.(LIALinkedInERROR错误1.)"

你可以在这里找到我正在使用的代码.

oauth linkedin ios

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