小编Tej*_*uri的帖子

如何在Xcode 6中下载应用程序数据

我可以在Xcode 5中的管理器窗口中下载我的应用程序数据,但是当我尝试在Xcode 6中执行相同操作时,我无法在管理器窗口中看到应用程序数据的选项下载.谁能告诉我怎么做?

ios xcode6

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

保存到 watchOS 2 文档文件夹

我的 iOS 应用程序将数据库发送到WatchKit (watchOS 2). 在WatchKit我使用以下代码来获取监视文档文件夹以保存新文件:

\n\n
NSURL* fileURL = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject] URLByAppendingPathComponent:@"MyDatabase.sqlite"];\n
Run Code Online (Sandbox Code Playgroud)\n\n

这会产生一个 URL:

\n\n
@"file:///var/mobile/Containers/Data/PluginKitPlugin/47E13085-9030-4ED2-906F-01CBA323F07A/Documents/MyDatabase.sqlite"\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是,当我调用该函数时:

\n\n
[[NSFileManager defaultManager] replaceItemAtURL:fileURL withItemAtURL:url backupItemName:nil options:0 resultingItemURL:nil error:&error];\n
Run Code Online (Sandbox Code Playgroud)\n\n

它抛出一个错误说:

\n\n
\n

错误域=NSCocoaErrorDomain代码=512“文件\xe2\x80\x9cMyDatabase.sqlite\xe2\x80\x9d无法\xe2\x80\x99t保存在文件夹\xe2\x80\x9cDocuments\xe2\x80\x9d中。” \n 错误域=NSCocoaErrorDomain 代码=513 “您\xe2\x80\x99t 无权保存文件\xe2\x80\x9cMyDatabase.sqlite\xe2\x80\x9d

\n
\n\n

我怎样才能找到一个允许我保存的文件夹?\n当然,这段代码在模拟器中工作得很好,所以我假设我错过了一些不太明显的东西。

\n\n

BR\n弗雷德里克

\n

objective-c watchos-2

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

使用大量UIImage时的内存问题

UIImage在一个阵列上存储大约100 个.我知道有一个内存使用问题最终导致应用程序崩溃,特别是在旧设备(iPhone 4s)上.在用户体验方面存储所有UIImages内容DocumentsDirectory- 不是一个选项(花费太长时间).所以我在考虑"合并"这两种方法.等到我收到内存使用警告,停止将图像保存到我的阵列,然后开始存储在磁盘上.我找不到正确的处理方式Memory leak/warning/usage call

 override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        print("memory warning")
    }
Run Code Online (Sandbox Code Playgroud)

当我在真实设备上进行测试时,它只是崩溃 - 没有调用方法.有什么建议?

memory memory-management uiimage swift

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

使用自定义字体时 UITextView 属性文本不起作用

我正在使用UITextView并通过代码设置其字体和属性文本。

案例 1: 自定义字体 - 是归属文本- 否

在此输入图像描述

textView 文本以自定义字体显示。

我想要带有自定义字体的属性文本,即消息:在这种情况下应加粗。

案例 2: 自定义字体 - 是归属文本- 是

在此输入图像描述

仅属性文本(粗体文本)以自定义字体显示。

我的代码是:

- (void)loadTextView
{
    _textView.text=NSLocalizedString(@"more_info_text",nil);
    _textView.font=[UIFont fontWithName:@"BurbankSmall-Medium" size:16];

    NSRange rangeBold  = [_textView.text rangeOfString:@"Examples of invalid characters:"];
    NSRange rangeBold2 = [_textView.text rangeOfString:@"Restricted text:"];
    NSRange rangeBold3 = [_textView.text rangeOfString:@"Message :"];

    UIFont *fontText = [self boldFontWithFont:_textView.font];
    NSDictionary *dictBoldText = [NSDictionary dictionaryWithObjectsAndKeys:fontText, NSFontAttributeName, nil];

    NSMutableAttributedString *mutAttrTextViewString = [[NSMutableAttributedString alloc] initWithString:_textView.text];
    [mutAttrTextViewString setAttributes:dictBoldText range:rangeBold];
    [mutAttrTextViewString setAttributes:dictBoldText range:rangeBold2];
    [mutAttrTextViewString …
Run Code Online (Sandbox Code Playgroud)

uitextview uifont ios nsmutableattributedstring

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

iOS 9 核心定位崩溃

我无法找出崩溃的原因CLClientCreateIso6709Notation

这里这里这里SO 问题中都提到了这一点,但它们与这个有点不同。

Crashlytics 返回的堆栈跟踪是:

Crashed: com.apple.CoreLocation.ConnectionClient.0x156c4f1a0.events
0  CoreLocation                   0x1896c4a20 CLClientCreateIso6709Notation + 51884
1  CoreLocation                   0x1896c4cc8 CLClientCreateIso6709Notation + 52564
2  CoreLocation                   0x1896c4c0c CLClientCreateIso6709Notation + 52376
3  CoreLocation                   0x1896c7a10 CLClientCreateIso6709Notation + 64156
4  CoreLocation                   0x1896c6ec4 CLClientCreateIso6709Notation + 61264
5  CoreLocation                   0x1896c5a60 CLClientCreateIso6709Notation + 56044
6  libxpc.dylib                   0x1825c8f68 _xpc_connection_call_event_handler + 68
7  libxpc.dylib                   0x1825ccdf0 do_mach_notify_port_destroyed + 124
8  libxpc.dylib                   0x1825ccd40 _Xmach_notify_port_destroyed + 80
9  libxpc.dylib                   0x1825cccc4 notify_server + 100
10 libxpc.dylib                   0x1825c6cd8 …
Run Code Online (Sandbox Code Playgroud)

google-maps objective-c core-location ios

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

在许多视图中模拟特定视图?

在我的项目中,我有大约20个视图.在xcode中是否有任何可能的方法来模拟特定视图?

例如:

视图的流程如下:

查看A ----->查看B ------>查看C ----->查看D.

如果我想去看D,我需要通过A,B,C.反正有没有跳过此流程并直接模拟View D?

注意:请建议我是否有另一种方法,而不是将'View D'作为初始视图控制器.

xcode ios-simulator

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

从 appdelegate 呈现一个视图控制器

我没有使用 LaunchScreen.xib 。我正在使用故事板作为闪屏。我正在调用 API 来获取启动图像。我正在应用程序委托中执行此操作。我可以在视图控制器上显示图像,但是一旦显示图像,我就无法转到另一个控制器。

这是我在 AppDelegate 中的内容:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{


self.window.frame=CGRectMake(0, 200, 100,30);

[self.window addSubview:[self convertImage: image]];

//upto here everything is fine

//now i am trying to wait for 3 seconds and call another view controller

sleep(3);

ViewController *login=[[ViewController alloc]initWithNibName:@"Login" bundle:nil];
[self presentviewcontroller:....]; // not able to present another controller

}
Run Code Online (Sandbox Code Playgroud)

objective-c ios appdelegate

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

使用 UIImages 创建 gif

我指的是这篇文章。我正在尝试使用屏幕截图创建的图像制作一个 gif 文件。我正在使用计时器来创建屏幕快照,以便获得可用于创建 gif 所需的帧数。我每 0.1 秒拍摄一次快照(稍后我将在 3 秒后结束此计时器)。

这是我的 UIView 快照的代码:

-(void)recordScreen{

   self.timer= [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(takeSnapShot) userInfo:nil repeats:YES];

}

-(void)takeSnapShot{

    //capture the screenshot of the uiimageview and save it in camera roll
    UIGraphicsBeginImageContext(self.drawView.frame.size);
    [self.drawView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

}
Run Code Online (Sandbox Code Playgroud)

我所指的帖子显示了创建 gif 的辅助函数。我不确定应该如何将图像传递给辅助函数。这是我尝试过的:

我尝试修改这部分:

 static NSUInteger kFrameCount = 10;
 for (NSUInteger i = 0; i < kFrameCount; i++) {
        @autoreleasepool {
            UIImage *image = [self takeSnaphot];
            CGImageDestinationAddImage(destination, image.CGImage, (__bridge CFDictionaryRef)frameProperties);
        }
    }
Run Code Online (Sandbox Code Playgroud)

这将创建包含 10 帧我的 …

objective-c gif cgimage ios

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

Touch ID 的 VoiceOver 辅助功能标签

我正在努力确保我正在开发的 iOS 应用程序是可访问的,并且正在尝试实施 VoiceOver 以确保这一点。

我找不到任何帮助的一件奇怪的事情是显示 Touch ID 视图时(在我的情况下用于登录应用程序)。VoiceOver 将 ID 发音为单词而不是 ID

我尝试为 NSString 和 LAContext 对象实现可访问性属性,但似乎都没有改变 VoiceOver 读出的内容。代码片段如下:

LAContext *context = [[LAContext alloc] init];
[context setIsAccessibilityElement:YES];
[context setAccessibilityLabel:@"TEST 2"];

NSError *error = nil;

NSString *label = @"Please authenticate your ID using the Touch ID";
[label setIsAccessibilityElement:YES];
[label setAccessibilityTraits:UIAccessibilityTraitStaticText];
[label setAccessibilityLabel:@"TEST"];

showingTouchID = TRUE;

if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
            localizedReason:label
                      reply:^(BOOL success, NSError *error) {
......
Run Code Online (Sandbox Code Playgroud)

带有或不带有可访问性属性的上下文的 VoiceOver 的输出始终是标签文本。

非常感谢所有帮助:)

objective-c ios voiceover uiaccessibility touch-id

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

如何在UINavigationBar中水平放置backIndicatorImage

我使用此代码将插图添加到backIndicator导航栏的图像。但是,这仅适用于图像的垂直定位。我只能将图像移至顶部或底部,而不能移至左侧或右侧。看起来左/右插图无效。我不确定可能是什么问题。

 UIEdgeInsets insets = UIEdgeInsetsMake(0, 20, 0, 0); //(20,0,0,0) works fine
 UIImage *backArrowImage = [[UIImage imageNamed:@"Back"] imageWithAlignmentRectInsets:insets];

 [[UINavigationBar appearance] setBackIndicatorImage:backArrowImage];
 [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backArrowImage];
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

  UIImage * backArrowImage =[[UIImage imageNamed:@"Back"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 0) resizingMode:UIImageResizingModeStretch];
Run Code Online (Sandbox Code Playgroud)

如果无法做到这一点,我是否需要返回添加自定义后退按钮?

objective-c uinavigationbar ios uiedgeinsets

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