我正在实施单元测试。原始项目是用Objective-C编写的。
我创建了一个用Swift编写的新测试目标。
如何在测试文件中调用实际应用程序的Objective-C类?
我尝试做以下。
@testable import MyModule
Run Code Online (Sandbox Code Playgroud)
但是,这似乎仅在所有文件都在Swift中时才起作用,而对我而言并非如此。
我在项目设置中尝试了其他几项,但是这些似乎都不起作用。
我是否明显遗漏了一些东西?
class MyTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
let vc = HomeViewController() //this line is failing. How do I expose this …Run Code Online (Sandbox Code Playgroud) 在XCode 8之前,您可以通过按字母顺序排列给定XCTestCase类中的测试方法的名称来使单元测试以特定顺序运行(如本答案中所述).例如,测试将运行如:testA,testB,testC,testD等.
但是在XCode 8中,情况已不再如此.例如,我将首先运行名为test1,test2,test3,test4和test4的测试方法(参见下面的屏幕截图).然后我可以重新运行,test2将在下一次运行时首先运行.
那么......如何在XCode 8上按顺序运行测试...?
从xcode 7更新到xcode 8之后,我面对的是没有故事板.任何人都可以提供帮助.里面没有显示任何错误.
我需要传递密钥,即使没有值,因为密钥在服务器端是必需的.但是Retrofit在发送请求时删除了具有空值的键.如何使用Retrofit将没有值的密钥发送到服务器?
请求正文如下:
{
"first_name":"testlogin",
"last_name":"lastname",
"username":"testman",
"password":"test123",
"email":"tester@test.com",
"address1":"123+test+way",
**"address2":"",**
**"address3":"",**
"postal_code":"75023",
"country":1,
**"state":""**
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我想制作一个适合标签大小的字符串。下面的代码不会改变任何东西。我究竟做错了什么?
nameLabel.font = UIFont.systemFont(ofSize: 30)
nameLabel.adjustsFontSizeToFitWidth = true
nameLabel.text = "fjggfjghggiuhgughuohgoihiohiohiughiugyiugyu8ftufuyguoy80houhuiy78rt6drtyreruti"
nameLabel.numberOfLines = 1
nameLabel.minimumScaleFactor = 0.5
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 iPhone 上调试应用程序 (Xamarin.Forms)。我已经在我的 Windows PC 上安装了 Visual Studio(我正在其上编写应用程序),并且在我的 Mac 上安装了 Visual Studio 和 Xcode。我也在我的开发者帐户上注册了 iPhone。
但是,我似乎还需要一个配置文件。但我见过的演练有与当前 Xcode 不同的屏幕。当我单击“首选项 - 帐户”时,我会看到我的帐户,但没有地方可以添加配置文件。
(iPhone 是否需要使用与 Mac 上(我拥有开发者帐户)相同的 Apple ID 登录?)
我该如何添加呢?
\n\n\n问题
\n\n必须对下面的代码进行哪些更改才能确保 Messenger 能够很好地处理
\nUIActivityViewController并共享图像和文本,或者至少共享图像?
背景
\n\n我用来UIActivityViewController分享我的应用程序中的文本和图像,并将它们发送到电子邮件、消息和其他共享应用程序。UIActivityViewController很棒,并且可以以简单且标准的方式与大多数应用程序\xe2\x80\xa6 配合使用,但是,我\xe2\x80\x99m 与 Messenger (Facebook Messenger) 存在问题,它不想\xe2\x80\x99 合作。
在下面的代码中,我点击 aUIButton来拍摄屏幕的快照图像,将其转换为 .png,然后将准备好的图像 ( imageShare) 连同我准备的文本 ( textShare) 一起发送到UIActivityViewController. 这个简单的方法允许我的应用程序成功共享到电子邮件、消息和除 Messenger 之外的许多其他共享应用程序。
(旁注,Facebook 只能分享准备好的图像 ( imageShare),但不能分享文本。)
问题
\n\nUIActivityViewController这些是尝试与 Messenger共享时出现的问题:
分享时activityItems: [textShare, imageShare]
分享时activityItems: [textShare]
UIActivityViewController.optimization ios uiactivityviewcontroller facebook-messenger swift
我正在尝试将UISearchController添加到包含UITableView(以及MKMapView的UIViewController)中,但希望这不是问题。我遵循了Ray Wenderlich的教程,但是就行为而言,我无法获得相同的结果。
这是我的viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
// Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = NSLocalizedString("Search references by project, customer or city", comment: "")
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
} else {
tableView.tableHeaderView = searchController.searchBar
}
definesPresentationContext = true
self.modeSelector.layer.cornerRadius = 5.0
if let split = splitViewController {
let controllers = split.viewControllers
detailViewController = (controllers[controllers.count - 1] as! UINavigationController).topViewController as? ReferenceViewController
}
self.navigationItem.rightBarButtonItem?.isEnabled = false
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试检索仍显示在通知中心的所有已发送通知,但UNUserNotificationCenter getDeliveredNotifications(completionHandler:)无法正常工作。我可以获得所有待处理的通知,UNUserNotificationCenter getPendingNotificationRequests(completionHandler:)但getDeliveredNotifications即使通知中心有通知,也只会返回 0 计数。
ios ×6
swift ×4
objective-c ×3
unit-testing ×2
xcode ×2
xcode8 ×2
android ×1
optimization ×1
retrofit2 ×1
rx-android ×1
storyboard ×1
swift3 ×1
uilabel ×1
uitableview ×1
xamarin.ios ×1
xcode9 ×1
xctestcase ×1