小编Nis*_*ndi的帖子

尺寸等级中的色域究竟是什么?

当您想向属性添加变体时,您会看到此弹出窗口(我使用的是 Xcode 8):

在此处输入图片说明

据我了解,这里的色域设置是针对显示类型的。但我不明白它的真正含义以及何时应该使用它?

xcode ios size-classes xcode8

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

完成处理程序swift 3从函数返回一个变量

我很困惑围绕swift 3中的完成处理程序的语法.

在下面的函数中,在xml从Web服务调用解析文件后,它应该返回一个变量(an array [String:String]).
我的尝试在下面,但显然是不正确的.

  enum HistoryKey {
  case success([String:String])
  case failure(String)
 }

 private func getHistoryKeys(searchterm: String, completion: @escaping () -> HistoryKey) {
    let url = PubmedAPI.createEsearchURL(searchString: searchterm)
    let request = URLRequest.init(url: url as URL)
    let task = session.dataTask(with: request) { (data, response, error) in

        if let theData = data{
            let myParser = XMLParser.init(data: theData)
            myParser.delegate = self
            myParser.parse()
        }
    }
    task.resume()

    if keys.isEmpty {
        return .failure("no historyKeyDictionary")
    }else{
        return .success(keys)
    }

}// End of func …
Run Code Online (Sandbox Code Playgroud)

ios completionhandler swift swift3

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

SKStoreReviewController requestReview 对话框中缺少文本

我正在尝试实现 StoreKit 的 requestReview API:

[SKStoreReviewController requestReview];
Run Code Online (Sandbox Code Playgroud)

当对话框出现时,它缺少“正在享受 [应用程序]?” 和“点击一颗星即可在 App Store 上对其进行评分”文本:

审阅对话框中缺少标题和说明

此屏幕截图来自运行 iOS 10.3.3 的 iPhone 6s。我还能够在运行 iOS 10.3.1 的 iPhone 6s 以及运行 iOS 10.3 的 iPhone 7 模拟器上重现该问题。

我知道开发模式和生产模式下的 UI 并不完全相同,但我的印象是开发模式中唯一的 UI 差异是提交按钮始终呈灰色。

如果我在开发中看不到它正常工作,我会犹豫是否使用此功能。

有什么想法如何让标题和描述出现或者可能导致此问题的原因是什么?

ios skstorereviewcontroller

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

使用自动调整大小的iPhone X蒙版迁移项目

我们有一些旧项目仍在使用“自动调整大小”蒙版,并且在iOS 11和iPhone X之前一切正常。通过引入安全区域布局指南,支持iPhone X的最佳解决方案是什么?

  1. 我们可以使用自动调整大小的掩码将所有接口转换为使用自动布局。考虑到正在动态添加和调整视图,这似乎是一项巨大的工作。

  2. 我们继续使用自动调整大小的蒙版,但会调整界面以增加iPhone X和iOS 11的插入边距。

ios autoresizingmask ios11 safearealayoutguide

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

如何将类从Swift Cocoapod导入Swift项目?

我用Swift语言创建了自己的pod(包含Swift语言中的类).该pod已发布.

我创建了新项目并创建了pod(via pod init)使用pod名称和版本以及使用use_frameworks!行编辑它

之后pod install它被下载.所以我可以.xcworkspace在项目中的文件中打开并查看我的pod.

但我不能在我的项目中导入需要的类.这该怎么做?

import xcode cocoapods swift

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

ios:我想在tableview的顶部和底部添加边框

我在 viewdidload() 中应用了以下代码,但使用此代码边框已到达但它随表格内容滚动。我想在顶部和底部修复边框。

这里我的代码是->

    let topBorder = CAShapeLayer()
    let topPath = UIBezierPath()
    topPath.move(to: CGPoint(x: 0, y: 0))
    topPath.addLine(to: CGPoint(x: tblFilter.frame.width, y: 0))
    topBorder.path = topPath.cgPath
    topBorder.strokeColor = UIColor.red.cgColor
    topBorder.lineWidth = 1.0
    topBorder.fillColor = UIColor.red.cgColor
    tblFilter.layer.addSublayer(topBorder)

    let bottomBorder = CAShapeLayer()
    let bottomPath = UIBezierPath()
    bottomPath.move(to: CGPoint(x: 0, y: tblFilter.frame.height))
    bottomPath.addLine(to: CGPoint(x: tblFilter.frame.width, y: tblFilter.frame.height))
    bottomBorder.path = bottomPath.cgPath
    bottomBorder.strokeColor = UIColor.red.cgColor
    bottomBorder.lineWidth = 1.0
    bottomBorder.fillColor = UIColor.red.cgColor
    tblFilter.layer.addSublayer(bottomBorder)
Run Code Online (Sandbox Code Playgroud)

给我建议,谢谢

layer uitableview ios swift

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

Xcode 9 - Info.plist中的位置使用说明 - iOS 11

我刚刚更新到Xcode 9.0正式版,当我运行使用位置服务的应用程序时,它工作正常但控制台打印出以下警告:

The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data
Run Code Online (Sandbox Code Playgroud)

所以我试图在我的Info.plist中添加以下密钥:

 <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>This app needs your current location</string>
Run Code Online (Sandbox Code Playgroud)

但是当我再次尝试运行应用时,Xcode 9会显示一条警告:无法读取数据,因为数据格式不正确.

所以我切换回:

<key>NSLocationAlwaysUsageDescription</key>
Run Code Online (Sandbox Code Playgroud)

该应用程序工作正常.哦,我的Info.plist已经包含了NSLocationWhenInUseUsageDescription键!

这是控制台中的Xcode 9错误吗?有人得到同样的警告吗?

location ios swift ios11 xcode9

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

如何将Swift 3内置的cocoapod更新为Swift 4

所以我已经下载了Xcode 9测试版,我的任务是将我们的一个内部pod从Swift 3更新到Swift 4.我已经克隆了repo,并打开它,可以查看所有项目文件和其他所有内容,但没有计划,我无法使用,Edit > Convert > Convert to current Swift syntax因为它是灰色的.

在主项目中,我使用了迁移工具,然后手动完成并添加了@objc以暴露Objective-C中引用的内容,但我似乎无法使用pod进行操作.

我只是想知道是否有人有任何更新pod到Swift 4的经验,如果是这样我怎么去做,因为网上的信息很少.

非常感谢,一如既往

尼尔

xcode cocoapods swift swift4

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

iOS信标区域监控需要启用蓝牙

我正在开发一个具有信标区域监控功能的应用程序。下面是监控信标区域的代码。

-(void)setBeaconMonitoringForUUID:(NSString *)strID withMajor:(NSString *)strMajor withMinor:(NSString *)strMinor withIdentifier:(NSString *)strIdentifier {
    NSUUID *strUUID = [[NSUUID alloc] initWithUUIDString:strID];
    CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:strUUID major:[strMajor intValue] minor:[strMinor intValue] identifier:strIdentifier];
    [beaconRegion setNotifyEntryStateOnDisplay:YES];
    [beaconRegion setNotifyOnEntry:YES];
    [beaconRegion setNotifyOnExit:YES];
    [self.objLocationManager startMonitoringForRegion:beaconRegion];    
    [self.objLocationManager startRangingBeaconsInRegion:beaconRegion];}
Run Code Online (Sandbox Code Playgroud)

locationManager初始化如下

- (id)init
{
   self = [super init];
   if (self != nil)
   {
      self.objLocationManager = [CLLocationManager new];
      self.objLocationManager.delegate = self;
      self.objLocationManager.distanceFilter = 10.0;
      self.objLocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
      self.objLocationManager.allowsBackgroundLocationUpdates = YES;

      if ([self.objLocationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
        [self.objLocationManager requestAlwaysAuthorization];
      }    
      [self.objLocationManager startUpdatingLocation];

  }
  return self;
}
Run Code Online (Sandbox Code Playgroud)

现在的问题是,为了监控信标区域,iOS …

bluetooth objective-c core-location ios ibeacon

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