这是我尝试过的没有用的东西:
以下是我所想到的不起作用:
以下是我正在考虑的选项:
确认UIDocumentInteractionController在Xcode 6.5中工作,但流程有点不稳定.NSURL的东西应该也可以,但它也有点可疑.有没有人有任何其他的想法让我的包含应用程序从共享扩展打开,或从共享扩展与它通信的想法?
根据Apple的App扩展编程指南:
运行应用扩展程序的内存限制明显低于前台应用程序的内存限制.在这两个平台上,系统可能会积极地终止扩展,因为用户希望在主机应用程序中返回其主要目标.某些扩展可能具有比其他扩展更低的内存限制:例如,窗口小部件必须特别有效,因为用户可能同时打开多个窗口小部件.
App Extension具有非常严格的内存约束,并且彼此不同.
每种类型的App Extension的最大内存预算是多少?
我可以测试它们像iOS App ios app最大内存预算吗?
我在NSItemProvider对象上使用loadItemForTypeIdentifier:options:completionHandler:方法,通过iOS 8中的Share扩展从Safari中提取url.
在Objective-C中,此代码和工作以及块运行.
[itemProvider loadItemForTypeIdentifier:(@"public.url" options:nil completionHandler:^(NSURL *url, NSError *error) {
//My code
}];
Run Code Online (Sandbox Code Playgroud)
在Swift中,它看起来非常相似,但是关闭不会运行.此外, itemProvider.hasItemConformingToTypeIdentifier("public.url")返回YES所以必须有一个有效的对象来解析内部的URL itemProvider.
itemProvider.loadItemForTypeIdentifier("public.url", options: nil, completionHandler: { (urlItem, error) in
//My code
})
Run Code Online (Sandbox Code Playgroud)
Info.plist NSExtension部分与Objective-C和Swift版本完全相同,如下所示:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
<key>NSExtensionPointName</key>
<string>com.apple.share-services</string>
<key>NSExtensionPointVersion</key>
<string>1.0</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
</dict>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在使用iOS 8自定义键盘,我使用像笑脸一样的图像来设计键盘.我希望这个键盘可以与iMessage一起使用.当我试图发送文本工作正常但无法在那里分享图像.我试过以下代码:
分享文字:(其工作正常)
-(void)shouldAddCharector:(NSString*)Charector{
if ([Charector isEqualToString:@"Clear"]) {
[self.textDocumentProxy deleteBackward];
} else if([Charector isEqualToString:@"Dismiss"]){
[self dismissKeyboard];
} else {
[self.textDocumentProxy insertText:Charector];
}
}
Run Code Online (Sandbox Code Playgroud)
添加图片:(不工作)
-(void)shouldAddImage:(UIImage*)oneImage
{
UIImage* onions = [UIImage imageNamed:@"0.png"];
NSMutableAttributedString *mas;
NSTextAttachment* onionatt = [NSTextAttachment new];
onionatt.image = onions;
onionatt.bounds = CGRectMake(0,-5,onions.size.width,onions.size.height);
NSAttributedString* onionattchar = [NSAttributedString attributedStringWithAttachment:onionatt];
NSRange r = [[mas string] rangeOfString:@"Onions"];
[mas insertAttributedString:onionattchar atIndex:(r.location + r.length)];
NSString *string =[NSString stringWithFormat:@"%@",mas];
[self.textDocumentProxy insertText:string];
}
Run Code Online (Sandbox Code Playgroud)
是否有可能将图像传递给 [self.textDocumentProxy insertText:string];
以下附图显示了我想要如何使用此图像键盘.我很惊讶表情符号键盘会起作用吗?
我正在为Safari进行动作扩展,我需要在扩展中获取所选文本.
通常在iOS中,我使用此代码在webview中获取所选文本
selectedText.text = [WebView stringByEvaluatingJavaScriptFromString: @ "window.getSelection (). toString ()"];
Run Code Online (Sandbox Code Playgroud)
但在扩展内部我不知道该怎么办!
为了完整性,它应该是IU的扩展,我只是打开NSExtensionActivationSupportsWebURLWithMaxCount以在Safari中提供扩展.
提前致谢
我正在尝试使用我作为按钮放入的图像为iOS构建自定义键盘.当我按下按钮时,链接到该按钮的图像被放入一个属性字符串,该字符串被加载到自定义键盘视图内的UiTextView中.那很有效.
问题是,当我将新图像附加到属性字符串时,字符串中的旧图像和新图像都将更改为我当前按下的图像.我无法理解为什么字符串中的旧图像正在发生变化.
有什么建议?我已经尝试使用replaceCharactersInRange和insertAttributedString但无法使其工作.这是代码(在viewDidLoad之后):
let textAttachment = NSTextAttachment()
let textView = UITextView(frame: CGRectMake(5, 5, 200, 40))
var attributedString = NSMutableAttributedString(string: "")
@IBAction func buttonPressed(button :UIButton) {
let string = button.titleLabel?.text
textAttachment.image = UIImage(named: "\(string!).png")!
textAttachment.image = UIImage(CGImage: textAttachment.image!.CGImage!, scale: 6, orientation: .Up)
let attrStringWithImage = NSAttributedString(attachment: textAttachment)
attributedString.appendAttributedString(attrStringWithImage);
textView.attributedText = attributedString;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我希望我的应用程序能够解析笔记应用程序帖子以及其他文本编辑器帖子中的文本,因此我创建了一个共享扩展目标.一切正常,直到我准备发布的应用程序,取代TRUEPREDICATENSExtensionActivationRule.
据说,在我的共享扩展目标中,我应该将NSExtensionActivationSupportsText密钥添加到info.plist中的NSExtensionActivationRule,我这样做了,但我的应用扩展程序仍未显示在共享表中.
根据https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html我的info.plist应该包含:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<integer>1</integer>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
我尝试启用其他类型,如附件,文件,网页,但没有效果.
iOS扩展 - 致命异常:com.firebase.core已配置默认应用程序.
我运行Fir.configure()在viewDidLoad中()方法和一些事件经过,并打通火力地堡.
有人可以帮我解决这个问题吗...谷歌不够友好.
PS:是的我在Firebase控制台中创建了第二个.plist和第二个应用程序.PPS:是的我为每个GoogleServices plist选择了正确的目标
我正在寻求解决方案..
我正在开发应用程序并共享扩展并尝试使用核心数据.但是当我在扩展中插入项目时,这些项目仅在扩展中可见但不是从容器应用程序中可见(例如,我从应用程序执行NSFetchRequest并获得零项目,但在app中我得到> 0).我使用以下代码获取持久性容器:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "appname")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error {
fatalError("Unresolved error \(error)")
}
})
return container
}()
Run Code Online (Sandbox Code Playgroud)
此外,还会检查appname.xcdatamodeld的目标成员应用程序和扩展程序.如何正确共享容器应用和扩展的核心数据?
我有一个项目
MyAppMyKit.frameworkMyExtension我想使用的共享代码MyKit的MyExtension,但是当我联系了,我得到的警告
ld: warning: linking against a dylib which is not safe for use in application extensions: /Users/me/Library/Developer/Xcode/DerivedData/MyApp-dnztzmxjghjlsteetlokzhjtjqkm/Build/Products/Debug-iphonesimulator/MyKit.framework/MyKit
Run Code Online (Sandbox Code Playgroud)
要配置应用程序扩展目标以使用嵌入式框架,请将目标的"仅限应用程序扩展安全API"构建设置设置为"是".如果不这样做,Xcode会提醒您这样做,方法是显示警告"链接到dylib并不安全,无法在应用程序扩展中使用".
默认情况下正确设置.我可以通过将"仅限App-Extension-Safe API"设置为NO来消除警告,但这可能会导致某些应用程序被拒绝.
该框架不使用应用程序扩展中不允许的任何API.实际上,在示例项目中,您将看到MyKit.framework仅将消息记录到控制台.
从应用程序扩展链接到嵌入式框架的正确方法是什么,以避免这种错误?