标签: xcode8

Xcode 8,禁用类级别属性

在Xcode 8中,Objective-C略有改变.现在有类级属性.例如,NSBundle的标头

@interface NSBundle : NSObject {
...

/* Methods for creating or retrieving bundle instances. */
#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, strong) NSBundle *mainBundle;
#endif

+ (nullable instancetype)bundleWithPath:(NSString *)path;
- (nullable instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;

+ (nullable instancetype)bundleWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);
- (nullable instancetype)initWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);

+ (NSBundle *)bundleForClass:(Class)aClass;
+ (nullable NSBundle *)bundleWithIdentifier:(NSString *)identifier;

#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, copy) NSArray<NSBundle *> *allBundles;
@property (class, readonly, copy) NSArray<NSBundle *> *allFrameworks;
#endif
...
Run Code Online (Sandbox Code Playgroud)

看看,主要包.现在它被声明为property但是带有class关键字.我认为它代表着class level …

xcode objective-c appcode xcode8

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

如何在Xcode 8中按顺序调用XCTest测试用例函数?

XCTest测试功能按字母顺序调用(在Xcode 8之前)。使用Xcode 8,我无法假定系统以哪种顺序调用测试用例。

有人可以照亮它吗?

function xctest xcode8

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

使用SKAction.scale更改Sprite的比例

试图让精灵'PlayButton'的比例继续向上和向下扩展以暗示用户触摸它.似乎无法让它工作.

这是菜单类:

import SpriteKit

class MenuScene: SKScene {

let ScalePBup = SKAction.scaleX(to: 300, y: 300, duration: 10)
let ScalePBdown = SKAction.scaleX(to: -300, y: -300, duration: 10)

//MARK: - Private Instance Variables
private let logo = GameLogo()
private let title = GameTitle()
private let playButton = PlayButton()
private let background = Background()
private let foreground = Foreground()
private let background2 = Background2()

//MARK: - Init
required init ?(coder aDecoder: NSCoder){
    super.init(coder:aDecoder)
}
override init(size: CGSize){
    super.init(size: size)
}
override func didMove(to …
Run Code Online (Sandbox Code Playgroud)

ios sprite-kit swift xcode8

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

UIActivityController共享URL文件

我想共享一个在应用程序中创建的URL文件和一个文本.但它似乎只能共享文本,而不是URL或UIImage.我正在使用的代码:

let sharedVideo = Video(Title: _data[1], VideoID: _data[0], Duration: _data[3], ViewCount: _data[2])
let  sharedURL = VideoManager.exportData(video: sharedVideo)
let shareItems:Array = [sharedURL,"check this out baby!"] as [Any]

let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)

self.present(activityViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

此外,我使用UIImage对象而不是sharedURL来查看它是否有URL问题.

即使使用图像文件也不起作用.当我点击内部的分享按钮时UIActivityViewController,它只适用于文本,没有URL或图像.我在Xcode 8中使用Swift 3.

谢谢.

PS:我确信sharedURL对象不是nil也不是undefined.

ios uiactivityviewcontroller swift swift3 xcode8

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

在“查看为”部分中,未显示iPhone IB而不是iPad:Xcode 8

我的应用程序仅适用于iPad,但在xib 上的“作为控制台查看”中,仅显示iPhone IB。 在此处输入图片说明

请建议我如何手动更换iPad IB。

注意- 我不在此应用程序中使用自动版式

xib ipad xcode8

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

检测Internet连接并显示UIAlertview Swift 3

我正在创建一个应用程序,通过使用if else语句检测是否存在与Internet的连接,当有互联网时,除了没有互联网连接之外什么也不做,然后提醒视图说应用程序需要互联网我管理发现可达性但是在我的viewDidLoad()上实现uialertview似乎无法正常工作.我用这个:

public class Reachability {
class func isConnectedToNetwork() -> Bool {
    var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
    zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress))
    zeroAddress.sin_family = sa_family_t(AF_INET)

    let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) {
        $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {zeroSockAddress in
            SCNetworkReachabilityCreateWithAddress(nil, zeroSockAddress)
        }
    }
    var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(rawValue: 0)
    if SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) == false {
        return false
    }
    let isReachable = flags == .reachable
    let needsConnection = …
Run Code Online (Sandbox Code Playgroud)

uialertview reachability ios swift3 xcode8

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

如何从didRegisterForRemoteNotificationsWithDeviceToken函数ios swift 3中删除几乎匹配的可选需求警告?

自从我将xcode更新为xcode 8后,我收到此警告:

实例方法

application(:didRegisterForRemoteNotificationsWithDeviceToken :)'几乎匹配协议'UIApplicationDelegate的可选要求'application(:didRegisterForRemoteNotificationsWithDeviceToken :)'

Xcode要求我通过将此函数设为私有来使这个警告静音,但是当我这样做时,函数从未被调用过(它不会被调用).

我试图删除功能,然后自动完成填充它,但没有任何效果.

这是有警告的功能:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    //
}
Run Code Online (Sandbox Code Playgroud)

这是我完整的appDelegate文件:

@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate,UNUserNotificationCenterDelegate,CLLocationManagerDelegate {

    var window: UIWindow?
    var locationManager:CLLocationManager?
    var coordinate: CLLocationCoordinate2D?
    func locationManagerStart() {

        if locationManager == nil {
            print("init locationManager")
            locationManager = CLLocationManager()
            locationManager!.delegate = self
            locationManager!.desiredAccuracy = kCLLocationAccuracyBest
            locationManager!.requestWhenInUseAuthorization()
        }

        print("have location manager")
        locationManager!.startUpdatingLocation()
    }

    func locationManagerStop() {
        locationManager!.stopUpdatingLocation()
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        //
        let newLocation = …
Run Code Online (Sandbox Code Playgroud)

push-notification ios swift swift3 xcode8

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

在创建框架时,在XCode 8中找不到filename.h文件错误

我正在尝试使用这个步骤创建一个框架https://www.raywenderlich.com/65964/create-a-framework-for-ios

我已经将框架文件导入到项目中,我可以为框架文件创建对象并访问方法.但是当我构建项目时,它告诉我找不到文件.

objective-c ios swift xcode8

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

Interface Builder文件中的未知类-Xcode 8 Swift 3

我遇到以下错误

接口生成器文件中的未知类TutorialViewController.swift。

重命名默认的文件时Main.storyboard,并ViewController.swift到我想要的命名规则TutorialView.storyboardTutorialViewController.swift分别。

我通过重命名Xcode中的文件名并更新的类名来重命名了文件TutorialViewController.swift

重命名后,我试图修复与链接TutorialView.storyboardTutorialViewController.swift通过更新故事板是Custom ClassTutorialViewController,这是完成链接的正确方法。实际上,这导致了上述错误。

免责声明:我知道这类似于此SO帖子,但是我想提出这个问题并回答我的解决方案,因为该帖子没有被接受的答案。我希望我能一直花点时间解决这个问题。

xcode interface-builder autolayout swift3 xcode8

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

NSAppleMusicUsageDescription-缺少Info.plist键

我添加了电子邮件建议的密钥,还添加了下拉列表中的密钥。

我清理了项目。我不知所措。

这是来自Apple的电子邮件:

缺少Info.plist键-此应用尝试访问对隐私敏感的数据,而没有使用说明。该应用程序的Info.plist必须包含一个NSAppleMusicUsageDescription键,该键具有字符串值,向用户解释该应用程序如何使用此数据。

在此处输入图片说明

在此处输入图片说明

objective-c ios xcode8

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