小编Cod*_*der的帖子

由于部署目标早于设备版本,着色器性能数据可能不可用

简而言之,我只想知道我是否应该关注这个问题:

运行时:GPU帧捕获:

由于部署目标早于设备版本,着色器性能数据可能不可用

我使用的设备运行iOS 12.0,当我将应用程序设置为目标iOS 12时,此问题没有出现.

但是,在我将应用程序的目标更改为11.4之后,就会出现这种情况.

基于我对它的阅读,以及我的应用程序在更改后的性能,我认为这不是真正令人担忧的,只是存在提醒我可能在获取着色器性能数据时遇到问题.

如果没有对11.4设备进行测试,我能做什么甚至应该做什么,去除它?

iphone xcode ios sprite-kit

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

静态成员不能在协议元类型Swift上使用

我正在尝试为我拥有的协议类型创建一个闭包,但是我收到以下错误

静态成员'menuItemSorter'不能用于协议元类型'MenuItem.Protocol'

这是我试图在操场上运行的代码的简化版本.

protocol MenuItem {
    var order: Int {get}
}

extension MenuItem {
    static var menuItemSorter: (MenuItem, MenuItem) -> Bool {
        return { $0.order < $1.order }
    }
}

class BigItem : MenuItem {
    var order: Int = 1
}

let bigItems = [BigItem(), BigItem()]

let sorter = MenuItem.menuItemSorter
Run Code Online (Sandbox Code Playgroud)

我希望能够在MenuItem上有一个类/静态var方法,可以对menuItems进行排序,这是最好的方法吗?

ios swift

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

尝试获取应用程序方向时,iOS 13.0 中不推荐使用“statusBarOrientation”

简单地说,我依靠以下代码来提供应用程序的方向。在应用程序中使用它有几个原因:

  • 根据 UX 规范,stackview 的布局是根据 iPad 的方向设置的(横向时为水平,纵向时为垂直)
  • 在上一项的基础上,stackview 被放置在屏幕的左侧(纵向)或顶部(横向)
  • 有自定义轮换逻辑,根据状态做出不同的响应。tl;dr 是在 iPad 上,该应用程序在方向之间呈现出显着差异

在这种情况下,我只是负责维护,并且无法做出偏离当前(并且正常运行)布局逻辑的重大更改。

截至目前,它依赖于以下内容来捕获应用程序方向:

var isLandscape: Bool {
    return UIApplication.shared.statusBarOrientation.isLandscape
}
Run Code Online (Sandbox Code Playgroud)

但是,对于 Xcode 11 GM 版本,我收到了以下弃用警告:

'statusBarOrientation' 在 iOS 13.0 中被弃用:改用窗口场景的 interfaceOrientation 属性。

如何通过状态栏获取应用程序的方向?

ios swift ios13

30
推荐指数
5
解决办法
2万
查看次数

在Swift 3.0中创建目录

我是一名9年级学习快速学习的新生,创建了一个学校项目.

我正在尝试创建一个目录,我想将扫描的文件保存为pdf格式.

在创建目录时,我收到以下错误.

错误1:

不能在属性初始值设定项中使用实例成员'filemgr'; 属性初始化程序在'self'可用之前运行.

错误2:

预期的声明

码:

let filemgr = FileManager.default


let dirPaths = filemgr.urls(for: .documentDirectory, in: .userDomainMask)

let docsURL = dirPaths[0]

let newDir = docsURL.appendingPathComponent("data").path

do{
    try filemgr.createDirectory(atPath: newDir,withIntermediateDirectories: true, attributes: nil)
} catch {
    print("Error: \(error.localizedDescription)")
}
Run Code Online (Sandbox Code Playgroud)

请协助我解决这个问题.

谢谢.

ios swift swift3

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

Swift 3:十进制到Int

我尝试使用以下代码将Decimal转换为Int:

Int(pow(Decimal(size), 2) - 1) 
Run Code Online (Sandbox Code Playgroud)

但我得到:

.swift:254:43: Cannot invoke initializer for type 'Int' with an argument list of type '(Decimal)' 
Run Code Online (Sandbox Code Playgroud)

在这里我知道pow正在返回a Decimal但似乎Int没有构造函数和成员函数可以转换DecimalInt.
如何在Swift 3中将Decimal转换为Int?

nsdecimalnumber ios swift swift3

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

iOS检查应用程序是否可以访问麦克风

随着iOS 7的推出,应用程序必须在想要录制音频时请求麦克风访问.

如何检查应用程序是否可以访问麦克风?
在iOS 8 SDK中我可以使用AVAudioSessionRecordPermission枚举,但如何在iOS 7中检查?

信息:
我不想请求权限,我只想检查应用是否可以访问麦克风.(如位置访问权限):

if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
    // Do something
}
Run Code Online (Sandbox Code Playgroud)

microphone objective-c ios avaudiosession swift

24
推荐指数
6
解决办法
4万
查看次数

SwiftUI displayModeButtonItem 内部管理

每次导航到另一个屏幕时,我都会在控制台中收到此消息:

[Assert] displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract.
Run Code Online (Sandbox Code Playgroud)

目前我在应用程序的入口点设置了导航视图,就像这样

NavigationView {
        KeyboardView(matrixVM: matrixVM, isNavigationBarHidden: $isNavigationBarHidden)
            .background(Color("background")
            .edgesIgnoringSafeArea(.all))
            .navigationBarTitle("Workspace")
            .navigationBarHidden(self.isNavigationBarHidden)
            .onAppear {
                self.isNavigationBarHidden = true
        }
    }
Run Code Online (Sandbox Code Playgroud)

然后在 KeyboardView 里面我有导航链接

NavigationLink(destination: NotebookView(isNavigationBarHidden: $isNavigationBarHidden, saved: matrixVM), label: {
                            Text("Notebooks")
                                .font(.system(size: 14, design: .rounded))
                                .fontWeight(.medium)
                                .foregroundColor(Color("text"))
                                .padding(.trailing, 10)
                        })
Run Code Online (Sandbox Code Playgroud)

在 NotebookView 中,我有一个导航链接列表(每个笔记本链接到其详细信息页面)

ScrollView(showsIndicators: false) {
                        ForEach(notebooks, id: \.self) { notebook in
                            
                            NavigationLink(destination: ExpandedSnippet(matrixVM: saved ,notebook: notebook)
                                            .navigationBarTitle("Notebook", displayMode: .inline)) …
Run Code Online (Sandbox Code Playgroud)

swiftui xcode12

23
推荐指数
4
解决办法
7039
查看次数

框架未找到架构arm64的IOSurface

这个错误很奇怪.昨天一切都很好.我安装Xcode 9测试版,然后我使用Xcode 8在iPhone 6p,iOS 9.3.2上运行我的应用程序(我昨天可以这样做,我仍然可以运行应用程序在模拟器上)然后我得到这个错误.

我用Google搜索了错误,似乎没有人遇到此错误.

这是错误日志:

LD /用户/天池/库/开发商/ Xcode中/ DerivedData/GlobalDomain-dxjnqhelcuqfqkgiqyycgpwmzail /编译/产品/调试-的iPhoneOS /全球\ Domain.app/Global \域正常arm64 CD /用户/天池/桌面/ IOS /后备箱出口IPHONEOS_DEPLOYMENT_TARGET = 8.0 export PATH ="/ Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/ usr/local/bin :/ usr/bin:/ bin:/ usr/sbin:/ sbin"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app /Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -L /用户/天池/库/开发商/ Xcode中/ DerivedData/GlobalDomain-dxjnqhelcuqfqkgiqyycgpwmzail /编译/产品/调试-的iPhoneOS -L /用户/ tianchi/Desktop/ios/trunk/GlobalDomain -L/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/GDWeChatPay -L/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK/Support/PlatformSDK/WeChatSD K -L/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon -L/Users/tianchi/Desktop/ios/trunk -F/Users/tianchi/Library/Developer/Xcode/DerivedData/GlobalDomain-dxjnqhelcuqfqkgiqyycgpwmzail/Build /产品/ Debug-iphoneos -F /用户/ tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK/Support/Optional -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK/Support/PlatformSDK/QQSDK -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK/Support/Required -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/MobileAnalytics -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/GDAlipaySDK -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/TencentIM -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/UMeng -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon/ShareSDK/Support/PlatformConnector -F/Users/tianchi/Desktop/ios/trunk/GlobalDomain/GDCommon -filelist/Users/tianchi/Library/Dev eloper/Xcode中/ DerivedData/GlobalDomain-dxjnqhelcuqfqkgiqyycgpwmzail /编译/中间体/ GlobalDomain.build /调试-的iPhoneOS /全球\ Domain.build/Objects-normal/arm64/Global\Domain.LinkFileList -Xlinker -rpath -Xlinker @ executable_path /框架 - miphoneos-version-min …

xcode ios

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

错误域= AVFoundationErrorDomain代码= -11800"操作无法完成.错误域= NSOSStatusErrorDomain代码= -16170"(null)"

我在聊天应用程序中使用AVPlayer但是我在选定的音频文件中遇到了错误但是音频文件在浏览器中正确播放.

错误域= AVFoundationErrorDomain代码= -11800"操作无法完成"UserInfo = {NSUnderlyingError = 0x60800024fde0 {Error Domain = NSOSStatusErrorDomain Code = -16170"(null)"},NSLocalizedFailureReason =发生未知错误(-16170),NSLocalizedDescription =操作无法完成}

我正在实现以下方法.

-(void)setupAVPlayerForURL:(NSURL*)url
 {
    AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
    AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];
    playerAud = nil;
    playerAud = [AVPlayer playerWithPlayerItem:anItem];
    [self startTimer];
    [playerAud play];
    [anItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopAudioPlay) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
}

And also implement the fallowing observer.

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    //// playerAud is instance of AVPlayer 
    if (object == playerAud.currentItem && …
Run Code Online (Sandbox Code Playgroud)

ios

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

禁用UISearchBar

我有一个 - 我希望 - 非常简单的问题:如何在IOS5中禁用UISearchBar以避免用户交互?我找不到setEnabled或类似的东西......

谢谢!

xcode objective-c uisearchbar ios ios5

17
推荐指数
3
解决办法
9736
查看次数