我有一个UICollectionViewCell包含a 的自定义子类UIScrollView.
滚动视图正确滚动,但是它会截取水龙头,因此集合视图单元格突出显示和选择无法按预期工作.
设置userInteractionEnabled以NO使水龙头"通过",但滚动没有(当然)工作.
覆盖hitTest:withEvent:是没有用的,因为我需要知道它是转发之前的点击还是平移.
有什么想法吗?
uiscrollview touch-event uigesturerecognizer ios uicollectionviewcell
我正在使用 xcode 5 为 iPhone 开发应用程序,我使用轻量级迁移来更新核心数据架构。
我在模型版本 1 中创建了一个 User 实体,User有一个名为nameA.
在模型版本2,我重命名User的nameA到nameB,我设置nameB的重命名id来nameA。这一步是成功的,之前的值nameA可以在 中找到nameB。
然后,我创建的模型版本3添加一个名为另一个实体House,我在3版本中发现,User“SnameB仍然有其重命名ID设置nameA
我认为在模型版本 3 中,User'snameB不应该具有重命名 ID,因为模型版本 3 基于版本 2,而在版本 3 中我没有更改任何User实体
那么我应该删除User's的重命名 IDnameB吗?还是把它留在那里?
有谁知道怎么做?
我正在尝试创建CIFilter如下的子类:
class ColorMonochromeFilter: CIFilter {
required init(red: CGFloat!, green: CGFloat!, blue: CGFloat!) {
super.init(name: "ColorMonochrome")
setDefaults()
let colour = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
setValue(colour, forKey: kCIInputColorKey)
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
似乎指定的初始化程序是init(coder aDecoder: NSCoder!)由于CIFilter符合NSCoding协议,而不是init(name: String!)在的扩展名中声明的CIFilter。
我可以通过添加以下内容来消除第一个错误:
required init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
Run Code Online (Sandbox Code Playgroud)
(尽管这似乎有些多余!)
有没有办法解决第二个问题?
我想在这里实现的是Swift的等效功能:
@implementation ASHColorMonochromeFilter
+ (ASHColorMonochromeFilter *) filterWithRed: (CGFloat) red green:(CGFloat)green blue:(CGFloat)blue
{
ASHColorMonochromeFilter * filter = (ASHColorMonochromeFilter …Run Code Online (Sandbox Code Playgroud) 我使用视图控制器作为模态.我想从下到上指定它的高度.这意味着它从底部到高度打开.我用波纹管代码打开模态:
let popUpVc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NewController") as! NewController
self.addChildViewController(popUpVc)
//Transition from bottom
let transition = CATransition()
transition.duration = 0.5
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromTop
view.window!.layer.add(transition, forKey: kCATransition)
popUpVc.view.frame = self.view.frame
self.view.addSubview(popUpVc.view)
popUpVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
popUpVc.didMove(toParentViewController: self)
Run Code Online (Sandbox Code Playgroud)
请帮我..
我只是想弄清楚为什么以下代码泄漏内存,我有一种有趣的感觉,我没有正确释放阵列内存.这是一个更广泛的Objective-c应用程序中的C函数,我不是C的原生...我曾尝试在数组上使用free(),但感觉这不是整个故事......
有人可以看一看,看看我在这里缺少什么.谢谢!
CFIndex theNumberOfSettings = 3;
CTParagraphStyleSetting theSettings[3] =
{
{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &alignment},
{kCTParagraphStyleSpecifierLineSpacing, sizeof(lineSpacing), &lineSpacing},
{kCTParagraphStyleSpecifierHeadIndent, sizeof(headIndent), &headIndent}
};
CTParagraphStyleRef theParagraphRef = CTParagraphStyleCreate(theSettings, theNumberOfSettings);
CFAttributedStringSetAttribute(attrString, CFRangeMake(0, CFAttributedStringGetLength(attrString)-1), kCTParagraphStyleAttributeName, theParagraphRef);
CFRelease(theParagraphRef);
free(theSettings);
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中收到一个随机错误,导致它崩溃.我面临的问题是XCode没有告诉我崩溃发生在哪里只有以下信息.有人能告诉我如何找到我可能在代码中找到问题的位置吗?它必须在应用程序崩溃的同一时间崩溃,它总是显示如下.
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSCFDictionary setObject:forKey:]:尝试插入nil值(键:0)'*首先抛出调用堆栈:(0x381e48bf 0x37d301e5 0x381e47b9 0x381e47db 0x381516bb 0x9237b 0x91121 0x8f0c5 0x8abc1 0x37b9d 0x8b68f 0x3550850f 0x381b0577 0x3813c0cf 0x3547c3fb 0x3547dc2b 0x8d005 0x3814322b 0x34495 0x32e31 0x3372d 0x30a59 0x3813e435 0x7b1df 0x7b88d 0x79e25 0x31ca650f 0x31ca5f01 0x31c8c4ed 0x31c8bd2d 0x37f12df3 0x381b8553 0x381b84f5 0x381b7343 0x3813a4dd 0x3813a3a5 0x37f11fcd 0x31cba743 0x89e8b 0x24a4)终止叫做抛出异常(LLDB)
根据我上一个问题的答案,我有 2 个协议\xe2\x80\xa6
\n\nprotocol Filters: Encodable { \n}\n\nprotocol QueryParameters: Encodable {\n associatedtype T: Filters\n var page: Int { get }\n var filters: T { get }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n然后对于类型Transaction,我有\xe2\x80\xa6
struct TransactionFilters: Filters {\n var isWithdrawal: Bool\n}\n\nstruct TransactionParamters<T: Filters>: QueryParameters {\n var page: Int\n var filters: T\n}\nRun Code Online (Sandbox Code Playgroud)\n\n到目前为止一切都很好。
\n\n接下来我添加一个协议 ,Filterable并且我希望任何符合该协议的类型都Filterable能够返回参数,如下所示\xe2\x80\xa6
protocol Filterable {\n func parameters() -> QueryParameters\n}\n\nstruct Transactions: Filterable {\n func parameters() -> QueryParameters {\n let transactionFilters = TransactionFilters(isWithdrawal: …Run Code Online (Sandbox Code Playgroud) 我已经有一段时间遇到这个问题了,在这里看了几十个答案,似乎找不到任何有用的东西。
我正在我的应用程序的 iOS 端生成一个二维码,并希望将此二维码发送到我目前正在开发的 WatchKit 扩展。
func createQR(with string: String) {
if let filter = CIFilter(name: "CIQRCodeGenerator") {
//set the data to the contact data
filter.setValue(string, forKey: "inputMessage")
filter.setValue("L", forKey: "inputCorrectionLevel")
if let codeImage = filter.outputImage {
return UIImage(ciImage: codeImage);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想从 QR 图像中获取数据,以便将其发送到 Apple Watch 应用程序,如下所示:
let data = UIImagePNGRepresentation(QRCodeImage);
Run Code Online (Sandbox Code Playgroud)
但是,这总是会返回,nil因为没有图像数据支持过滤器的输出。
注意:我知道没有与 CI Image 关联的数据,因为它没有被渲染,甚至没有与之关联的数据,因为它只是过滤器的输出。我不知道如何解决这个问题,因为我对图像处理等很陌生。:/
cgImage从filter.outputImagefunc createQR(with string: String) {
if let filter …Run Code Online (Sandbox Code Playgroud) 使用NativeScript如何在iOS下运行项目?我跑的时候收到这些消息tns run iOS --bundle
Webpack compilation complete. Watching for file changes.
Webpack build done!
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Installing pods...
Analyzing dependencies
Downloading dependencies
Installing Socket.IO-Client-Swift (11.1.3)
Installing StarscreamSocketIO (8.0.7)
Installing Toaster (2.0.4)
[!] Unable to determine Swift version for the following pods:
- `Socket.IO-Client-Swift` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute …Run Code Online (Sandbox Code Playgroud) 我正在创建PDF阅读器类型的应用程序,我正在使用PDFKit该应用程序显示PDF文件.
我能够PDFView通过代码添加它的工作正常.
但是有可能我可以PDFView通过storyboardOutlet 添加,而不是通过Outlet我将PDF文件分配给该视图吗?
ios ×7
swift ×5
cocoa ×2
iphone ×2
apple-pdfkit ×1
c ×1
cifilter ×1
cocoapods ×1
core-data ×1
debugging ×1
generics ×1
ios11 ×1
nativescript ×1
objective-c ×1
storyboard ×1
touch-event ×1
uiscrollview ×1
vue.js ×1
xcode ×1
xcode4.3 ×1
xcode5 ×1