标签: xcode8

设置 CocoaPods 主仓库 (Sierra)

升级到 Sierra 10.12 后,从头开始全新安装,我无法使用 cocoapods 安装库,通过进行“pod install”我得到了这个:“Setting up CocoaPods repo master”。我希望你能帮助我。谢谢你。

installation cocoapods xcode8

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

在 Tableview 中使用 BezierPath 创建时间轴视图

我试图在 TableView 中绘制一个具有 5 行的里程碑,我在单元格中添加了一个标签为“O”,这里的行高是 44,我试图连接这些点像这样的东西 O------O-- ----O------O-----O 垂直,但我无法弄清楚这里缺少什么,请参考以下代码

 class StopslistTableViewCell:UITableViewCell{

@IBOutlet weak var milestoneLbl: UILabel!

override func draw(_ rect: CGRect) {

    let scrrenX = UIScreen.main.bounds.width - 30

    let frametosuperview = milestoneLbl.convert(milestoneLbl!.frame, to: self.superview)

    print("dotframetosuperview",frametosuperview)

    //print(CGPoint(x: scrrenX, y: previousposY + rect.size.height))

    //frametosuperview.origin.y > 40 ? frametosuperview.origin.y - 20 : frametosuperview.origin.y

    let path = UIBezierPath()
    path.move(to: CGPoint(x: scrrenX, y:frametosuperview.origin.y < 30 ? frametosuperview.origin.y : frametosuperview.origin.y - frametosuperview.height))

    print("move to point--->",frametosuperview.origin.y < 30 ? frametosuperview.origin.y : frametosuperview.origin.y - frametosuperview.height)

    path.addLine(to: CGPoint(x: scrrenX, …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3 xcode8

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

Ionic/cordova:如何使用 fastlane 或 xcodebuild 添加推送功能?

我有一个使用 Ionic.io 推送消息的 Ionic 项目。它使用 Fastlane 构建并通过 HockeyApp 部署。

由于升级到 Xcode 8 推送通知不再适用于 iOS 10。

我有一个包含推送授权的授权文件,它使用 ruby​​ 脚本添加到 xcode 项目文件中,请参阅https://github.com/fastlane/fastlane/issues/6544

当我使用 Fastlane push 构建项目时,仍然无法正常工作。当我在 Xcode 中打开项目文件并查看功能部分时,它在“将推送通知权利添加到您的权利文件”中显示了一个复选标记,但在“将推送通知功能添加到您的应用程序 ID”中显示了一个错误。

如果我按“修复”并重建, push确实有效

所以我的问题是:

我希望能够正确启用推送功能,只使用 Fastlane、xcodebuild、ruby 或其他任何东西,只要它仅在命令行中并允许我的 ionic 项目干净地构建。

xcodebuild ionic-framework fastlane ios10 xcode8

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

像 Swift 中的 Uber iOS 应用程序一样在 Google Map 上移动注释?

我正在尝试开发基于 Uber 和 Ola 之类的概念的应用程序。因此,为此我需要集成 Google Map 以获取 iOS 的接送位置。所以请告诉我如何使用谷歌地图在iOS中实现移动注释(汽车)动画。

iphone google-maps ios swift3 xcode8

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

为什么不管延迟的值如何调用 audioplayer.play(atTime: delay) 都不发出声音

预计:

当 audioplayer.play(atTime: 1) 被调用时,计时器重置为 0,并且在第一秒播放音频播放器

现实:

我尝试了 delay = 0.000000001, 1, 100000000,但无论如何,都不会播放噪音。然而,代码被清楚地执行了(因为“函数被调用”出现在控制台中)

为什么会出现差异?

C = AVAudioPlayer() // assume other setups are done
C.play(atTime: 1)
print("function was called")
Run Code Online (Sandbox Code Playgroud)

delay avaudioplayer swift xcode8

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

XCUITest 获取 URL 值

我正在使用 XCUITest 和 XCode 版本 8.3.3。该应用程序有一个登录按钮,可启动浏览器窗口。想知道是否有人可以告诉我如何访问打开的 URL 的值。我想验证我们在选择“登录”按钮时启动了正确的 URL。

let app = XCUIApplication()
let loginButton = app.buttons["Login"]
loginButton.tap()
Run Code Online (Sandbox Code Playgroud)

此时浏览器窗口打开:在此输入图像描述

如何获取 xyz.com 的价值?

使用辅助功能检查器,我可以看到: 在此输入图像描述

ios ios-ui-automation xctest xcode-ui-testing xcode8

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

在 UIScrollView Swift3 中加载 UIViewController

我有 2UIViewController秒。一个UIViewController有很多按钮的视图,高+2000点。另一个UIViewController有一个UIScrollView.

这是我的代码:

import UIKit

 class ViewController: UIViewController {

@IBOutlet weak var scrollView: UIScrollView!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


    scrollView.contentSize = CGSize(width: 375, height: 2884)

    DispatchQueue.main.async {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let thumb_vc = storyboard.instantiateViewController(withIdentifier: "thumb") as! ThumbsViewController
        //self.present(vc, animated: true, completion: nil)

    self.addChildViewController(thumb_vc)
    self.scrollView.addSubview(thumb_vc.view)
   }
 } 
Run Code Online (Sandbox Code Playgroud)

尽管拇指UIViewController加载到UIScrollView,但大小错误且不滚动。

任何帮助表示赞赏

ios swift3 xcode8

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

如何防止 Storyboard 调整(拉伸)以 UIView 为中心的 UIImage 的大小?

我有一个通用的 iOS 应用程序,并且正在尝试从旧式启动图像移动到故事板启动屏幕上的简单居中图像,所以我有一个适用于所有设备的故事板。当应用程序在尺寸大于图像的设备上运行时,我的图像(640x1136,iPhone 5s 尺寸)不需要被拉伸——换句话说,UIView 的背景颜色应该出现在较大设备上的图像周围。出于调试目的,我将视图背景颜色更改为艳丽的 Lime。

根据最高投票的答案(Suragch 的),我按照SO 帖子中的指示在 UIImageView 上定义了 2 个约束,实际上还必须遵循已接受的答案的建议来添加额外的 UIView,其中我的 UIImageView 将包含在其中。

UIImageView 的“内容模式”是中心,所以看起来应该没有拉伸。

在图片中注意 UIImageView 的 Xcode 大小检查器设置。UIView 具有 iPhone 7 大小的尺寸 (750x1334),因此因为 iPhone 比我的图像高,所以 UIImageView 的位置使其 X 为 55,Y 为 99。宽度和高度与图像本身相同 (640x1136)。

当我在模拟器中运行 iPhone 7 时,它看起来应该与 Xcode 的 Interface Builder 显示的完全一样(图像周围出现石灰色,但是,对于任何大于 iPhone 5s 或 SE 的设备,它看起来就像我所看到的图片附加(iPad Air,仅供参考)。您可以看出图像必须垂直拉伸很多,因为图像只有 1136 高。

我附上了 iPhone 7(模拟器)iPad Air 和 iPad Pro 的屏幕截图。请注意,iPad Air 的左右边缘出现了水平的石灰色条纹。请注意,当涉及到 iPad Pro 时,石灰背景颜色开始显示在图像上方。就好像在较小的设备上,系统正在拉伸 UIImageView,但是随着设备屏幕尺寸的增加,这最终会停止,直到对于最大的(Pro),您实际上可以看到周围的背景。对于Apple 文档列出的所有比 …

xcode constraints storyboard uiimageview xcode8

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

URL的Swift 3语法问题

我试图在Xcode 8中将C#示例转换为swift,但我一直遇到语法问题.查看代码的小例子:

public class ToonAPIClient {
    private var APIManagerBaseAddress: URL!
    private var APIBaseAddress: URL!

    public init() {
        APIManagerBaseAddress = URL(String: "https://path.to.baseurl/")
        APIBaseAddress = URL(String: APIManagerBaseAddress + "append/path/data/")
    }
}
Run Code Online (Sandbox Code Playgroud)

APIManagerBaseAddress我收到错误

参数标签'(String :)'与任何可用的重载都不匹配

并为APIManagerBaseAddress

二进制运算符'+'不能应用于'URL'类型的操作数 和'字符串'

任何帮助都很受欢迎,因为我尝试了一些语法可能性:)

-edit-感谢大家的帮助和建议!

swift swift3 xcode8

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

UIImagePickerController在没有NS照片库和相机描述的情况下工作

我正在使用UIImagePickerController,因为我正在创建一个应用程序,该应用程序允许通过照片库和照相机发布图像。我创建了一个基本的演示,其中包含一个UIImageView,UIButton和一些用于设置UIImagePickerController的代码。此外,我还在Xcode的plist部分中设置了(NSPhotoLibraryUsageDescription和NSCameraUsageDescription)。图像拾取功能可以很好地运行,但是当我运行模拟器时,没有询问我是否应该让该应用程序允许访问我的相机或照片库。然后,我尝试取消plist语句并再次运行。没有这些,应用程序应该崩溃,但不会崩溃。

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {


@IBOutlet weak var imageView: UIImageView!


@IBAction func importImage(_ sender: UIButton) {

    let imagePickerController = UIImagePickerController()
    imagePickerController.delegate = self

    let actionSheet = UIAlertController(title: "Add Your Profile Picture", message: "Choose An Option", preferredStyle: . actionSheet)

    actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: { (action:UIAlertAction) in
        if UIImagePickerController.isSourceTypeAvailable(.camera) {
            imagePickerController.sourceType = .camera
            self.present(imagePickerController, animated: true, completion: nil)
        }
        else {
            print("Camera not Available")
        }
    }))

    actionSheet.addAction(UIAlertAction(title: "Camera Roll", style: .default, handler:{ (action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary …
Run Code Online (Sandbox Code Playgroud)

uiimagepickercontroller ios xcode8 swift4

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