我想在Xcode 7上的Swift项目中导入我的自定义模块/框架.我理解如何正常地执行它.但我不想在每次创建新项目时继续拖放框架并将其链接起来.我以为我可以将框架移动到iPhoneOS.sdk /../ Frameworks文件夹和/或iPhoneSimulator.sdk /../ Frameworks文件夹中的文件夹.在不将我的自定义框架拖放到项目中的情况下,我可以导入模块(使用自动完成).但是我收到错误"无法构建Objective-C模块'Tumblr'".在构建设置中是否存在我缺少的设置.
**Tumblr模块是我创建的模块.
我还为iPhoneOS.sdk中存在的框架创建了一个.tbd和module.map文件
我想做动画,例如"在滚动collection view cell结束时滚动注释引脚向上/向下滚动.但是当滚动结束时,如何开始滚动时注释引脚等动画上升,注释引脚变为向下collection view
//code --> For Scrolling
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
if scrollView == collectionView {
NSLog("page collection %d",Int(scrollView.contentOffset.x/scrollView.frame.size.width))
self.UpdateMapAnotationPin(Int(scrollView.contentOffset.x/scrollView.frame.size.width))
}
}
// -->When Update Pin
func UpdateMapAnotationPin(vIndex : Int) {
if self.mapAnnotations.count != 0 {
let info = self.mapAnnotations[vIndex]
let aView = map.viewForAnnotation(info)
info.imageName = "ic_map_pin1"
info.tagPin = vIndex
aView?.image = UIImage(named: info.imageName)
if aView != nil {
self.animationWithView(aView!)
}
}
}
// --> For animation
func animationWithView(mkView : MKAnnotationView) {
let point:MKMapPoint = MKMapPointForCoordinate(mkView.annotation!.coordinate); …Run Code Online (Sandbox Code Playgroud) 我刚刚安装Xcode 8 beta 2和iOS 10 beta.我有一个现有的项目,我根据Xcode的提示从swift 2.3更新到swift 3.我的代码数据代码收到错误.
这是由xcode从swift 2.3转换为swift 3时自动生成的
var fetchedResultsController: NSFetchedResultsController<AnyObject>!
Run Code Online (Sandbox Code Playgroud)
我收到的错误是
Type 'AnyObject' does not conform to protocol 'NSFetchRequestResult'
Run Code Online (Sandbox Code Playgroud)
我试图遵守AnyObject
extension AnyObject: NSFetchRequestResult {}
Run Code Online (Sandbox Code Playgroud)
但我收到另一个错误
我不确定我需要做什么,或者我的fetchedResultsController首先需要更改.
回答: var fetchedResultsController: NSFetchedResultsController<Content>!
我正在制作一个应用程序,扫描反转颜色的条形码(黑色背景和白色条).我必须使用AVFoundation.目前,我正在使用AVCaptureMetadataOutput.我可以使用正常的条形码完美地工作.我需要反转白色的颜色 - >黑色和黑色 - >白色等.我CIColorInvert可以在输入中添加一个AVCaptureSession
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
mCaptureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if([mCaptureSession canAddInput:videoInput]){
[mCaptureSession addInput:videoInput];
} else {
NSLog(@"Could not add video input: %@", [error localizedDescription]);
}
// set up metadata output and this class as its delegate so that if metadata …Run Code Online (Sandbox Code Playgroud) 我XCTest UI对Mac应用程序进行了相当正常的测试,该应用程序单击应用程序菜单中的某些菜单项以打开窗口.
在某些地方 - 比如我自己的Mac - 测试工作正常.但在其他地方 - 比如Travis CI- 他们失败了,出现了这个错误:
UI Testing Failure - Failed to receive event delivery confirmation within 2.5s of the original dispatch.
...
menuBarsQuery.menuBarItems["Top level menu item"].click()
menuBarsQuery.menuItems["Menu item in sub menu"].click()
Run Code Online (Sandbox Code Playgroud)
系统:
稍微消毒的测试用例版本:
import XCTest
class FooUITests: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
}
func testCanDoSomething() {
let app …Run Code Online (Sandbox Code Playgroud) 我有一个for循环,我希望在迭代之间添加延迟.我已将waitUntilDone更改为YES并获得相同的结果.我的数组中只有两个数字,并且在五秒后调用它们而不是:
0s - 没有5s - Block叫10s-Block叫
for(NSNumber* transaction in gainsArray) {
double delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
NSLog(@"Block");
[self performSelectorOnMainThread:@selector(private_addTransactionToBankroll:)
withObject:transaction waitUntilDone:NO];
});
}
2015-06-16 20:11:06.485 TestApp[97027:6251126] Block
2015-06-16 20:11:06.485 TestApp[97027:6251127] Block
Run Code Online (Sandbox Code Playgroud)
如果重要的话,我正在使用Cocos2d
for-loop objective-c delay cocos2d-iphone grand-central-dispatch
我正在对一种新的潜在产品进行初步研究。此产品的一部分要求iPhone和iPad上的“语音转文本”功能保持打开状态,直到用户将其关闭为止。自己使用它时,我注意到它要么在30秒钟左右自动关闭,无论用户是否停止讲话,或者在说话者发出一定数量的可疑词后关闭它。无论如何,该产品要求它始终保持打开状态,直到明确要求停止为止。以前有人为此工作吗?是的,我尝试了很好的搜索,似乎找不到任何实质内容,尤其是找不到用正确语言编写的内容。谢谢朋友!
我尝试通过我的应用发送电子邮件,但收到一个错误消息
“请设置邮件帐户以发送电子邮件”。
我的代码块在下面。
import MessageUI
@IBAction func emailTapped(_ sender: Any) {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(["abc@gmail.com"])
mailComposerVC.setSubject("Sending you an in-app e-mail...")
mailComposerVC.setMessageBody("Sending e-mail in-app is not so bad!", isHTML: false)
if MFMailComposeViewController.canSendMail() {
self.present(mailComposerVC, animated: true, completion: {() -> Void in })
}
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Swift.Error?){
controller.dismiss(animated: true) { () -> Void in }
}
Run Code Online (Sandbox Code Playgroud) 我有一个UIColor extension与enum命名为myColors:
enum myColors {
static let backgroundColor = UIColor(hex: "#373737")
static let strokeColor = UIColor(hex: "#FFFCF9")
static let red = UIColor(hex: "#FF6978")
static let green = UIColor(hex: "#BCE784")
static let blue = UIColor(hex: "#B1DDF1")
static let yellow = UIColor(hex: "#FFFD98")
static let purple = UIColor(hex: "#A09ABC")
}
Run Code Online (Sandbox Code Playgroud)
我试图将sprite颜色随机设置为这些颜色之一(红色,绿色,蓝色,黄色,紫色).我在Stack Overflow上找到的答案很少,但没有一个有用.我试着这样做:
let sprite = Player(x,y,color: myColors(rawValue: myColors.purple.rawValue+1)
Run Code Online (Sandbox Code Playgroud)
但它没有用.紫色是枚举的最后一项,所以我选择了它.
我正在将我的应用程序迁移到4.1并遇到此错误的一些麻烦:
Failure/Error: get :facebook
ActiveModel::MassAssignmentSecurity::Error:
Can't mass-assign protected attributes for Delayed::Backend::ActiveRecord::Job: priority, queue, payload_object
# ./app/models/user.rb:457:in `subscribe_to_mailchimp'
# ./app/controllers/users/omniauth_callbacks_controller.rb:14:in `facebook'
# ./config/initializers/log_formatter.rb:22:in `block (2 levels) in <top (required)>'
# ./config/initializers/log_formatter.rb:21:in `block in <top (required)>'
# ./spec/controllers/users/omniauth_callbacks_controller_spec.rb:23:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
规格:
describe Users::OmniauthCallbacksController, ci: true do
describe "when authenticating" do
let(:user) do
Fabricate(:user)
end
let(:social_media_account) do
Fabricate(:social_media_account, uid: "12345", provider: "facebook", user: user)
end
before do
term = Fabricate(:term, name: "application")
user.terms << term
Fabricate(:project)
end
it "redirects …Run Code Online (Sandbox Code Playgroud) 刚刚更新到Swift 3和xCode 8 Beta 4.
修复所有代码问题后,我现在有一个无错误的项目,但是当我点击我的前屏幕上的一个特定按钮时,它会抛出SIGABRT错误.
我确信它与目标页面上的UIPickerView元素有关,因为我已经删除,检查并重新添加了所有的segue和outlet以确保从那一方清楚一切.
控制台显示以下内容:
2016-08-02 18:59:46.607 ForceIt![38735:2895259] - [ForceIt_.DirectoryViewController numberOfComponentsInPickerView:]:无法识别的选择器发送到实例0x7fcd68c0c210 2016-08-02 18:59:46.618 ForceIt![38735:2895259]***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [ForceIt_.DirectoryViewController numberOfComponentsInPickerView:]:无法识别的选择器发送到实例0x7fcd68c0c210'
相关viewcontroller的代码如下:
import UIKit
var forceSelectedForTabView = String()
var forceSelectedPositionInArray = Int()
class DirectoryViewController: UIViewController, UIPickerViewDelegate {
@IBOutlet weak var forcePicker: UIPickerView!
@IBOutlet weak var selectedContactLabel: UILabel!
@IBOutlet weak var selectedPhoneTextView: UILabel!
@IBOutlet weak var selectedWebsiteTextView: UILabel!
//function for the number of columns in the picker
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
//function counting the array to …Run Code Online (Sandbox Code Playgroud) let result = ["response": response,
"callbackId": callbackId]
do {
let data = try NSJSONSerialization.dataWithJSONObject(result, options: .PrettyPrinted)
var str = NSString(data: data, encoding: NSUTF8StringEncoding) as? String
str = str?.stringByReplacingOccurrencesOfString("\\", withString: "\\\\")
str = str?.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
str = str?.stringByReplacingOccurrencesOfString("\'", withString: "\\\'")
str = str?.stringByReplacingOccurrencesOfString("\n", withString: "\\n")
str = str?.stringByReplacingOccurrencesOfString("\r", withString: "\\r")
// str = str?.stringByReplacingOccurrencesOfString("\f", withString: "\\f")
// str = str?.stringByReplacingOccurrencesOfString("\u2028", withString: "\\u2028")
// str = str?.stringByReplacingOccurrencesOfString("\u2029", withString: "\\u2029")
return "bridge.invokeJs('{\"response\" : {\"username\" : \"zhongan\"},\"callbackId\" : \(callbackId)}')"
} catch {
return …Run Code Online (Sandbox Code Playgroud) swift ×9
ios ×6
xcode ×3
objective-c ×2
activerecord ×1
avfoundation ×1
cocoa ×1
core-data ×1
delay ×1
email ×1
enums ×1
for-loop ×1
frameworks ×1
iphone ×1
mapkit ×1
mkmapview ×1
module ×1
omniauth ×1
ruby ×1
sigabrt ×1
swift3 ×1
uipickerview ×1
unicode ×1
xctest ×1