在过去,我以编程方式创建UIButton没有问题,但自从我使用Xcode 9和Swift 4以来,我找不到让这个错误消失的方法.
//Adding target to UIButton
func PositionStartButton(xOffset: Float){
StartButton.frame = CGRect(x: Int(0 - 40 + xOffset), y: 0, width: 80, height: 80)
StartButton.setImage(#imageLiteral(resourceName: "Logo_Final_WHITE_Face"), for: .normal)
StartButton.addTarget(self, action: "pressButton:", for: .touchUpInside)
ScrollView.addSubview(StartButton)
}
//The target function
func pressButton(_ sender: UIButton){
print("\(sender)")
}
Run Code Online (Sandbox Code Playgroud)
错误消息:'NSInvalidArgumentException',原因:' - [Playing.MainMenuViewController pressButton:]:无法识别的选择器发送到实例0x10440a6b0'
我有一个嵌入在导航控制器中的普通视图控制器.在这个视图控制器中,我有一个使用安全区域约束的表视图.(我不使用表视图控制器)
导航控制器设置为首选大型标题,模式设置为.always.在测试版2中,这非常有效,所以当我进入标题时,标题很大,当我向下滚动时它变小了(就像普通的一样).但是从beta 3开始,这不再适用了.
任何人都知道如何重新打开它,或者当我滚动表格视图时如何使它变得更小.喜欢所有新iOS 11应用程序的行为?
或者这是当前版本的swift 4/iOS 11中的一个错误,但是信使和设置之类的应用仍然以这种方式工作.
提前致谢.
我在Xcode 9 GM上运行我的iOS应用程序的单元测试,其中一些是因为奇怪的NSInternalInconsistencyException而失败,抱怨无法报告某些测试断言,因为所涉及的测试没有关联的XCTestRun对象.我正在使用OCMockito + OCHamcrest进行模拟和呼叫验证.
出于演示目的,假设我的应用程序名为MyTestApp,我有一个测试类FooTest(继承自XCTestCase).在-setUp中,我为测试创建并连接各种模拟对象,而在-tearDown中我将它们设置为nil以防万一.
这是我得到的例外情况的一个例子:
2017-09-19 13:23:01.852729-0700 xctest[17006:5392130] *** Assertion failure in -[FooTest recordFailureWithDescription:inFile:atLine:expected:], /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-13201/Sources/XCTestFramework/Core/XCTestCase.m:308
/Users/fooUser/Workspaces/MyTestApp/tests/FooTest.mm:46: error: -[FooTest testSomething] : failed: caught "NSInternalInconsistencyException", "Unable to report test assertion failure 'Expected 1 matching invocation, but received 0' from /Users/fooUser/Workspaces/MyTestApp/tests/FooTest.mm:135 because it was raised inside test case -[FooTest testSomethingElse] which has no associated XCTestRun object. This may happen when test cases are constructed and invoked independently of standard XCTest infrastructure."
(
0 CoreFoundation 0x000000010255d1cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000101ebff41 … 我在xcode 9中创建了一个新项目.
我想将图像文件添加到项目中.
当我从桌面删除此文件时,
图像文件显示为红色?
但是在项目文件夹中,我找到了这个图像文件.
在Xcode 8中它的工作正常,
任何的想法?
我在Xcode 9 Beta 3中使用了第三方库.我在完成调用中收到以下错误,我无法解决此错误:
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
self.animationView?.alpha = 0
self.containerView.alpha = 1
completion?() // -> Error: Missing argument parameter #1 in call.
}
Run Code Online (Sandbox Code Playgroud)
并在完成功能中获得以下警告:
func openAnimation(_ completion: ((Void) -> Void)?) {
// -> Warning: When calling this function in Swift 4 or later, you must pass a '()' tuple; did you mean for the input type to be '()'?
}
Run Code Online (Sandbox Code Playgroud) 我想在游乐场中使用一些CocoaPod库,但是在Xcode 9(beta 4)中看不到将操场与目标链接的方法.我认为这在早期的Xcode版本中是可行的,但在我当前的机器上没有早期版本的Xcode.
创建一个游乐场将其创建为未保存的Xcode文档组的一部分- 并在单独的窗口中打开它.
如何安装可以在操场上导入的吊舱? (如果需要,通过工作区或项目)
当我尝试在模拟器中运行应用程序时,我持有Xcode 8.3.2和Xcode 9 beta 1,我的项目在Xcode 8.3.2中运行.我得到了以下错误.
Images.xcassets: error: Failed to find a suitable device for the type SimDeviceType : com.apple.dt.Xcode.IBSimDeviceType.iPad-2x with runtime SimRuntime : 10.3 (14E269) - com.apple.CoreSimulator.SimRuntime.iOS-10-3
Failure Reason: Failed to create SimDeviceSet at path /Users/Mac/Library/Developer/Xcode/UserData/IB Support/Simulator Devices. You'll want to check the logs in ~/Library/Logs/CoreSimulator to see why creating the SimDeviceSet failed.
Underlying Errors:
Description: Failed to initialize simulator device set.
Failure Reason: Failed to subscribe to notifications from CoreSimulatorService.
Underlying Errors:
Description: Error returned in reply to …Run Code Online (Sandbox Code Playgroud) 我正在尝试在新的Xcode 9测试版中运行我当前的项目,但是当我这样做时它会说Module compiled with Swift 3.1 cannot be imported in Swift 4.0.我怎么解决这个问题?我不是在使用cocoapods.