我正在运行Xcode 6.1并且我已经在IBInspectable中使用IB_DESIGNABLE用于很多项目,但突然之间它就不再起作用了.我创建了子类按钮,将图像和标题垂直居中放置,使用户可以通过IBI使用IBInspectable设置边框宽度和颜色.
将记录以下警告,并且我无法在drawRect中预览我的代码:
warning: IB Designables: Ignoring user defined runtime attribute for key path "spacingBetweenLabelAndImage" on instance of "UIButton". Hit an exception when attempting to set its value: [<UIButton 0x7f9278591260> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key spacingBetweenLabelAndImage.
Run Code Online (Sandbox Code Playgroud)
仍然,运行时它渲染像我打算渲染它,它也尊重我通过IB添加的相同自定义间距.
这是重新排列按钮和标题的menubutton的代码:
#import "HamburgerButton.h"
IB_DESIGNABLE
@interface HamburgerImageButton : HamburgerButton
@property IBInspectable CGFloat spacingBetweenLabelAndImage;
@end
Run Code Online (Sandbox Code Playgroud)
执行:
#import "HamburgerImageButton.h"
@implementation HamburgerImageButton
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGSize imageSize = self.imageView.frame.size;
CGSize titleSize = self.titleLabel.frame.size;
// Move the label left and …Run Code Online (Sandbox Code Playgroud) 我做了一个非常简单的应用程序,可以在计时器运行时在后台运行.如果应用程序仍在后台并且计时器结束,它将发送本地通知并将应用程序徽章设置为1.当我启动应用程序时,我总是清除它.我注意到安装Xcode 6后,每次启动应用程序时都收到此消息:
"试图标记应用程序图标但未获得用户的许可以标记应用程序"
很明显,我的应用程序会将徽章设置为0以清除它.我在哪里设置这些权限或请求它们?它现在被视为推送通知吗?
问题已得到解决,答案如下.最重要的是,您需要获得用户对任何类型通知的确认,而过去只有推送通知才会确认.
我认为此错误消息是 Xcode 12 中的 SwiftUI 的新消息,因为它在 Google 中的点击率为 0,而该消息本身相当通用:
在安装在 View 之外访问 State 的值。这将导致初始值的常量绑定并且不会更新。
我有以下代码(删除了一些绒毛):
public struct ContentView: View {
@ObservedObject var model: RootViewModel
public var body: some View {
VStack(alignment: .center, content: {
Picker(selection: model.$amount, label: Text("Amount")) {
Text("€1").tag(1)
Text("€2").tag(2)
Text("€5").tag(5)
Text("€10").tag(10)
}.pickerStyle(SegmentedPickerStyle())
Text("Donating: €\(model.amount)").font(.largeTitle)
}).padding(.all, 20.0)
}
}
public class RootViewModel: ObservableObject {
@State public var amount: Int = 1
}
Run Code Online (Sandbox Code Playgroud)
我曾经有field权利,ContentView而且工作正常。现在 UI 不再更新,而是我收到了运行时警告。
我已经将Jenkins配置为轮询Git存储库,我使用的是https而不是ssh.配置了以下URL,我使用用户名和密码.
https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git
Run Code Online (Sandbox Code Playgroud)
当我运行构建时,它会停顿10分钟并超时.当我复制超时的行并将其粘贴到Jenkins运行的同一台机器上的命令行(macOS服务器)时,它可以工作:
git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
为什么它会停留10分钟?我试图使用错误的凭据,并且会在一秒钟内失败.这不是一个巨大的回购.
日志:
Started by user Jenkins Admin
Building in workspace /Users/Shared/Jenkins/Home/workspace/Build and test new commits on develop
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git # timeout=10
Fetching upstream changes from https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: …Run Code Online (Sandbox Code Playgroud) 我正在更新我的Xcode 9,Swift 4,iOS 11和iPhone X的应用程序.它似乎一直相对平滑,但每当我点击后退按钮我的应用程序崩溃.我可以毫无问题地前进3-4个屏幕但是第一个后退按钮总是会崩溃应用程序.它不需要模拟器作为iPhone X运行.
它似乎没有陷入我的代码堆栈跟踪,所以这在我看来视图控制器的重绘阶段,我正在弹出,但我不确定.
因为我做了很多自定义绘图,因为在UITableViews和UIViews周围有自定义阴影我在所有位置设置了断点,我将其除以一个变量,但没有任何东西被击中.所以它似乎不是我的代码用零进行计算.
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [nan 0; nan 0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010af711cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a8d3f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010afe5b95 +[NSException raise:format:] + 197
3 QuartzCore 0x0000000109424424 _ZN2CA5Layer10set_boundsERKNS_4RectEb + 230
4 QuartzCore 0x0000000109414c29 -[CALayer setBounds:] + 251
5 UIKit 0x0000000107267439 __27-[_UILabelLayer setBounds:]_block_invoke + 80
6 UIKit 0x000000010726717b -[_UILabelLayer _setFrameOrBounds:settingAction:] + 23
7 UIKit 0x00000001072673d8 …Run Code Online (Sandbox Code Playgroud) 我试图运行一个现有的应用程序,以查看它与最新的Xcode beta配合使用的情况,并尝试在现有项目中使用SwiftUI。在模拟器上运行项目时,出现以下运行时崩溃:
dyld: Symbol not found: __ZTISt11logic_error
Referenced from: /Users/lucas/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
in /Users/<name>/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Run Code Online (Sandbox Code Playgroud)
将所有内容都设置为iOS 13可以使错误消失,但是在不久的将来将无法使用。还尝试删除与音频和AV框架相关的所有内容,但无济于事。
我一直在使用 Xcode 12 beta 构建一个应用程序剪辑。根据文档,应用程序应该小于 10MB,但我无法查看我是否真的低于此限制。
我正在将现有的VoIP应用程序转换为Callkit.我有很多代码,但不知何故,当我初始化CXProvider时,它将调用providerDidBegin,然后立即调用providerDidReset.它没有给出理由.之后我无法注册其中一个外拨电话,因为我的提供商没有激活.
我已经尝试过查看证书,设置等等,但基本上我不需要比我已经拥有的VoIP应用程序更多.
CallKit调用reset方法的调用如下:
CallKit`__42- [CXProvider handleConnectionInterruption] _block_invoke:
当我深入挖掘它的来源时,它与NSXPCConnection有关.这是什么联系,我该如何设置它?
当然,连接没有中断.
这是我初始化我的代表的方式:
- (id)init {
self = [super init];
self.configuration = [[ProviderConfiguration alloc] init];
self.provider = [[CXProvider alloc] initWithConfiguration:self.configuration];
[self.provider setDelegate:self queue:dispatch_get_main_queue()];
return self;
}
Run Code Online (Sandbox Code Playgroud)
这就是配置的样子:
- (instancetype)init {
self = [super initWithLocalizedName:@"MyCompany"];
self.supportsVideo = NO;
self.maximumCallsPerCallGroup = 1;
self.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:(int)CXHandleTypePhoneNumber], nil];
self.maximumCallGroups = 1;
self.maximumCallsPerCallGroup = 5;
return self;
}
Run Code Online (Sandbox Code Playgroud)
两个回调都已实现:
- (void)providerDidBegin:(CXProvider *)provider {
NSLog(@"Begun");
}
- (void)providerDidReset:(CXProvider *)provider {
NSLog(@"Reset");
}
Run Code Online (Sandbox Code Playgroud) 我已经访问过这个答案,这里提出的present方法不起作用(不再?)。当我使用 aUIViewControllerRepresentable然后将其显示为工作表时,它看起来非常糟糕:
如果我使用overlay它,它看起来就像我想要的那样,但overlay不能从Button.
这是(精简的)代码:
public struct ContentView: View {
@ObservedObject var model: RootViewModel
@State private var tappedDonate = false
public var body: some View {
Button(action: {
tappedDonate = true
}, label: {
Text("Donate")
.frame(width: 300, height: 44, alignment: .center)
})
.frame(width: 300, height: 20, alignment: .center)
.padding()
.background(Color.black)
.foregroundColor(.white)
.cornerRadius(22)
.sheet(isPresented: $tappedDonate) {
ApplePayWrapper(request: model.buildApplePayment())
.background(Color.clear)
}
}
public init(model: RootViewModel) {
self.model = model
} …Run Code Online (Sandbox Code Playgroud) 我编写了以下代码,以帮助将文本值从表单字段转换为期望值:
protocol StringConvertableValueType {
init?(_ string: String)
}
extension Int: StringConvertableValueType {
}
extension String: StringConvertableValueType {
}
extension Double: StringConvertableValueType {
}
extension Float: StringConvertableValueType {
}
Run Code Online (Sandbox Code Playgroud)
如您所见,所有这些基本类型本身已经支持相同的初始化程序。但是,翻阅文档,我找不到能protocol做到这一点的任何共享。尽管感觉像我正在重新做一些创建Foundation的人已经完成的事情。
是否protocol已经有某种方法可以解决此问题,或者构建人员Foundation只是确保API确实是一致的,但是没有协议来强制执行?