小编Tej*_*uri的帖子

requestAccessForMediaType在iOS 10中崩溃

在我的应用程序中,我使用card.io扫描信用卡.它在iOS 9中运行良好.在iOS 10中,应用程序崩溃,我无法在xcode 8 beta 2控制台中找到崩溃日志,因为它会抛出大量垃圾邮件.

然后我检查了隐私 - >设置以查看我的应用程序是否禁用了相机,但我的应用程序未列在该部分中.请注意,iOS 10并未授权我的应用程序使用相机.

我使用以下代码来请求权限:

-(BOOL)checkCameraPermissions{

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if(authStatus == AVAuthorizationStatusAuthorized)
    {
        // start card-io
        return YES;
    }
    else if(authStatus == AVAuthorizationStatusNotDetermined)
    {

        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
         {
             if(granted)
             {
                 //Start card-io
                 [self testIsNewCard];
             }

         }];
    }
    else if (authStatus == AVAuthorizationStatusRestricted)
    {
        //Alert
        // Alert camera denied

        UIAlertController *aCon=[UIAlertController alertControllerWithTitle:@"Camera denied" message:@"Camera cannot be used" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *ok =[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [aCon dismissViewControllerAnimated:YES completion:nil];
        }]; …
Run Code Online (Sandbox Code Playgroud)

objective-c card.io ios10 xcode8-beta2

20
推荐指数
3
解决办法
4699
查看次数

如何更改Android中进度条的颜色? - (我尝试了一种方式,但它不起作用)

我使用以下代码为我的活动添加了一个进度条:

<LinearLayout
    android:id="@+id/linlaHeaderProgress"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:visibility="gone" >

    <ProgressBar
        android:id="@+id/pbHeaderProgress"
        android:indeterminateOnly="true"
        android:keepScreenOn="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </ProgressBar>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

然后我称之为:

 progressbar = (LinearLayout) findViewById(R.id.linlaHeaderProgress);
 progressbar.setVisibility(View.VISIBLE);
Run Code Online (Sandbox Code Playgroud)

将显示进度条,我想更改它的颜色.默认情况下,进度条以灰色显示.这是我试图改变颜色:

我在drawables文件夹中创建了一个xml文件,并将其命名activityindicator.xml 为此xml的内容为:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/secondaryProgress">


        <color android:color="#f58233" />
    </item>
    <item android:id="@android:id/progress">

        <color android:color="#f58233" />
    </item>

</layer-list>
Run Code Online (Sandbox Code Playgroud)

我将布局文件更改为:

<LinearLayout
    android:id="@+id/linlaHeaderProgress"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:progressDrawable="@drawable/activityindicator"
    android:orientation="vertical"
    android:visibility="gone" >

    <ProgressBar
        android:id="@+id/pbHeaderProgress"
        android:indeterminateOnly="true"
        android:keepScreenOn="true"
        android:progressDrawable="@drawable/activityindicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </ProgressBar>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这就是我尝试过的,但颜色并没有改变.谁能告诉我我做错了什么?

我正在使用Lollipop版本.

xml android android-linearlayout progress-bar android-drawable

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

在自己的应用程序中使用Yosemite上的图像编辑扩展

在我的OS X应用程序中,我想让用户编辑带有安装在他/她的Mac上的相应动作扩展的图像,例如Mail.app或TextEdit中的图像标记扩展(对于带有图像的RTFD文件) - 或Pixelmator的修复工具(如果有).据我所知,Apple在WWDC '14宣布将有一个公共API来完成这项任务.

遗憾的是,我找不到任何关于如何从主机应用程序角度使用扩展的起点,无论是文档还是样本代码.

我发现你必须将NSSharingPicker的未记录的样式属性设置为非零值,如下所示:

- (IBAction)testSharingPicker:(id)sender
{
    NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:@[[self.listing.images.firstObject thumbImage]]];

    [picker setValue:@(1) forKey:@"style"];
    [picker setDelegate:self];

    [picker showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
}
Run Code Online (Sandbox Code Playgroud)

一旦设置了样式值,您就知道自己处于正确的轨道上,因为- (NSArray *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items proposedSharingServices:(NSArray *)proposedServices我的系统上安装了图像编辑扩展,而不是常规的共享扩展.

您还需要实现一个未记录的委托方法:

- (BOOL)sharingServicePicker:(NSSharingServicePicker *)sharingService shouldShowForView:(NSView*) inView
{
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

但是,选择器还没有出现.我得到的只是sender按钮周围的一些奇怪的边框.

cocoa objective-c osx-yosemite

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

Xcode 6给出了CFNetwork内部错误

我最近安装了Xcode 6,当我试图在模拟器中运行应用程序时它运行正常,但它记录以下错误.我不知道这个错误是什么.任何人都可以说如何解决

CFNetwork internal error (0xc01a:/SourceCache/CFNetwork_Sim/CFNetwork-711.0.6/Foundation/NSURLRequest.mm:798)
Run Code Online (Sandbox Code Playgroud)

ios ios-simulator xcode6

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

ios8 unwind segue无法使用UINavigationBarController和UITabBarController(在iOS 8.1中已修复)

我刚开始使用Xcode 6(beta 6)在iOS8上测试我的iOS7应用程序.我知道iOS 8已经弃用了"推"和"模态"segue,但我很高兴地发现我所有的segue都工作了......除了一个.

我构建了一个演示应用程序,以显示如果您的应用程序使用带有UINavigationController的UITabBarController,则从模态segue展开似乎会被破坏.(我看到了另一个放松的segue帖子,但是它使用的是swift,我的演示应用程序使用的是obj-c).

以下是我更具体的看法:[UITabBarContoller] - > [UINavigationController] - > [SomeViewController] - (模态Segue) - > [此ViewController无法解除]

有趣的是,你可以放松,如果你做另一个模态segue:[UITabBarContoller] - > [UINavigationController] - > [SomeViewController] - (模态Segue1) - > [这个ViewController不能放松] - (Modal Segue2) - > [这个ViewController可以放松]

我还发现如果我删除UITabBarController或UINavigationController我可以放松,但我不打算改变我的整个应用程序UI架构:)

从我所看到的,根视图控制器永远不会收到对canPerformUnwindSegueAction的调用:fromViewController:withSender:它在iOS7中执行.

我的问题:我是否应该采用不同的方式让我放松工作?

谢谢阅读.

演示代码在这里:https://github.com/nmsasaki/UnwindDemo

UPDATE

这个问题似乎已经被iOS8.1修复了.(iOS 8.0解决方法是创建UINavigationController的自定义子类继续工作.)

objective-c ios8 xcode6-beta6 unwind-segue

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

如何调试 SwiftUI Widget 内存问题?

我正在 swiftui 中创建一个小部件,其中包含预填充的模拟 json,存储在本地。

模拟 JSON 有以下数据:

{
    "id":"111",
    "title":"some dummy title",
    "date":"1609865285",
    "thumbnail":"mock4"
}
Run Code Online (Sandbox Code Playgroud)

并且mock4图像存储在Assets文件夹中。

我在时间线方法中加载模拟数据,如下所示:

for mockItem in storyManager.getMockData() {
    let item = WidgetFeedItem(newsData: mockItem)
    items.append(item)
}
let entry = FeedItemEntry(date: Date(), items: entries)
if let nextDate = Calendar.current.date(byAdding: .minute, value: 15, to: Date()) {
    let timeline = Timeline(entries: [entry], policy: .after(nextDate))
    completion(timeline)
 }


 struct WidgetFeedItem: Hashable {
    var newsTitle = ""
    var newsDate = Date()
    var newsID = ""
    var newsimageURL = ""
    var articleLink = "" …
Run Code Online (Sandbox Code Playgroud)

xcode-instruments swift widgetkit swiftui ios14

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

AVSpeechSynthesizer的话语率在iOS7和iOS 9中有所不同

问题:在iOS 7.x和iOS 8.x中,此代码运行正常,但在iOS 9.x中,与iOS 7和8中的语音速率相比,语音速度变慢.

self.synthesizer = [[AVSpeechSynthesizer alloc] init];

self.synthesizer.delegate = self;

AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:[NSString stringWithFormat:@"Hey %@, please choose places to explore or select excursions to see our custom crafted deals",[defaults objectForKey:@"USERNAME"]]];

utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];

utterance.rate = 0.10;

[self.synthesizer speakUtterance:utterance]; 
Run Code Online (Sandbox Code Playgroud)

objective-c text-to-speech avspeechsynthesizer ios9 xcode7

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

如何在UIVisualEffectView上进行透明剪切?

在我的应用程序中,我通过UIView继承简单的UIView 来进行透视.但是,如果我尝试使用相同的UIVisualEffectView,我无法做到.

以下是我使用普通能够做到的事情UIView:

在此输入图像描述

当我使用UIVisualEffectView代替绿色时UIView,我看不到通过UIView看到,即使看到通过UIView添加到UIVisualEffectViewas subview.

在此输入图像描述

码:

- (void)drawRect:(CGRect)rect { //this is same for the UIVIew and for the UIVisualEffectView
    [super drawRect:rect];

    CGContextRef context = UIGraphicsGetCurrentContext();
    // Clear any existing drawing on this view
    // Remove this if the hole never changes on redraws of the UIView
    CGContextClearRect(context, self.bounds);

    // Create a path around the entire view
    UIBezierPath *clipPath = [UIBezierPath bezierPathWithRect:self.bounds];

    // Your transparent window. …
Run Code Online (Sandbox Code Playgroud)

objective-c uiview ios uivisualeffectview

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

ld:找不到架构i386的框架

我试图在我的框架中测试一个方法,我写了一个简单的测试用例.但它无法执行,xcode给我错误:

ld: framework not found V***ments for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我仔细检查了框架是否添加到嵌入式二进制文件中以及构建阶段部分.

这是我的测试文件:

import XCTest

@testable import MYClass


class MYClassTests: XCTestCase {

    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in …
Run Code Online (Sandbox Code Playgroud)

ios swift xctestcase xcode7.2

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

使用大量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
查看次数