我正在使用代码在我的应用程序中获取Airprint以将当前视图打印为图像.弹出Airprint对话框但在日志屏幕中它显示两个警告:
1)警告:在iPad上调用 - [UIPrintInteractionController presentAnimated:completionHandler:]无法找到PDF标题:找不到`%PDF'.
2)[UIPopoverController_commonPresentPopoverFromRect:inView:allowedArrowDirections:animated:]:传入此方法的rect必须具有非零的宽度和高度.这将是未来版本中的一个例外.
我已经在网上搜索过,但发现所有解决方案都提供了常规的rect按钮
我在这里使用的是一个分段控件,我不知道在这种情况下如何使用这个控件
这是段控制代码:
- (IBAction)legalSegment:(id)sender {
switch (((UISegmentedControl *)sender).selectedSegmentIndex) {
case 0:
{
[self printItem];
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是printItem方法:
-(void)printItem {
CGRect rect = CGRectMake(0, 0, 768, 1004);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIPrintInteractionController* pic = [UIPrintInteractionController sharedPrintController];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(img)];
if (pic && [UIPrintInteractionController canPrintData:imageData])
{
pic.delegate = self;
UIPrintInfo* printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputPhoto;
printInfo.jobName = @"PrintingImage";
printInfo.duplex = …Run Code Online (Sandbox Code Playgroud) 我正在尝试为端到端测试套件创建解决方案,以便在模拟器上设置用户权限(联系人,照片,通知等).这样做的原因是SpringBoard会显示权限警报,并且它们会干扰测试套件.
我已经尝试过使用XCUITest套件,但它对SpringBoard警报没有预期效果,并且一般不方便使用.
所以我的想法是修改系统文件,以便按需设置权限.我找到了TCC数据库,看起来非常简单.然后我注意到通知权限保存在不同的文件下/Library/BulletinBoard/SectionInfo.plist.此文件由BBServerSpringBoard进程中的对象缓存.我设法更改了此文件,如果SpringBoard终止,则接受对文件的更改.但我希望在测试应用程序的进程运行时期间发生此更改.
经过一番挖掘后,我注意到当设置应用程序(首选项)对通知设置进行更改时,它会使用XPC连接来通知它已进行了更改.
我试图在测试过程中完成同样的事情.我创建了一个BBSectionInfo包含通知所有设置的对象,并尝试使用a BBSettingsGateway在内部使用XPC连接通知BulletinBoard服务器.这不起作用,我不知道为什么不,因为我没有得到任何错误.
也许这是一个权利问题?令我恼火的是系统没有给出错误,没有任何反应.
在调试器中,带来XPC连接,我得到这个:
(lldb) po [inv.target valueForKey:@“connection”]
<NSXPCConnection: 0x60000011bcf0> connection to service named com.apple.bulletinboard.settingsconnection
Run Code Online (Sandbox Code Playgroud)
内部连接也没有透露任何问题:
(lldb) po [[inv.target valueForKey:@"connection"] valueForKey:@"xpcConnection"]
<OS_xpc_connection: connection[0x6000001a6200]: { refcnt = 2, xrefcnt = 1, name = com.apple.bulletinboard.settingsconnection, type = named, state = init-done, error = 0x0 mach = true, privileged = false, bssend = 0x6f07, recv = 0x6d0b, send = 0x7003, pid = 0, euid = 4294967295, egid = …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用设置一个背景图像,可以缩放以填充4,4.7和5.5英寸的屏幕.
我有一个带有搜索栏作为标题的 UITableView。当用户在搜索栏中进行搜索时,我使用此函数来更新我的数据。
func updateSearchResults(for searchController: UISearchController) {
if let searchText = searchController.searchBar.text {
if (searchText.characters.count > 0) {
self.filteredResults = [];
self.locationManager?.geocodeAddressString(addressString: searchText, completionHandler: { (results, error) in
if error == nil && results != nil {
self.filteredResults = results!;
self.tableView.reloadData();
}
});
}
else {
self.filteredResults = [];
self.tableView.reloadData();
}
}
}
Run Code Online (Sandbox Code Playgroud)
以及当我在 UITableView 中选择一个单元格时的这个功能。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.delegate?.setCity(city: str);
self.dismiss(animated: true, completion: nil);
}
Run Code Online (Sandbox Code Playgroud)
这是我的问题:在第一次点击单元格时,视图控制器不会关闭。我点击一次,搜索栏辞职响应者。我需要点击两次才能执行解雇。
这是我如何在 viewDidLoad 中链接我的 tableview 和搜索栏:
// Search Bar …Run Code Online (Sandbox Code Playgroud) 我有一个开源 Objective C 框架,我也想使用 Swift Package Manager 来提供它。
通常,我在 Xcode 项目中设置了公共标头,当构建框架时,这些标头会被复制到框架捆绑包下,并在由 Xcode 链接时被发现。
但我不能让它与 SwiftPM 一起工作。
我为我的框架创建了一个模块映射:
framework module LNPopupController {
umbrella header "LNPopupController.h"
export *
module * { export * }
}
Run Code Online (Sandbox Code Playgroud)
我在 Package.swift 中像这样定义库:
let package = Package(
name: "LNPopupController",
platforms: [
.iOS(.v12),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LNPopupController",
type: .dynamic,
targets: ["LNPopupController"]),
],
dependencies: [
// Dependencies declare other …Run Code Online (Sandbox Code Playgroud) 我使用NSPredicate通过州和国家列表过滤NSDictionary.
所有数据都以逗号分隔的数组存储:@"Alabama",@"Alaska",@"Arizona",@"Arkansas",@"California",@"Colorado"等
但是,有两种情况发生重复.州"新墨西哥州"包含"墨西哥"一词,"阿肯色州"包含"堪萨斯州"一词.
这是我用来定义谓词的基本代码.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Location contains[c] %@", @"Kansas"];
Run Code Online (Sandbox Code Playgroud)
我如何确保"堪萨斯"不会返回"阿肯色州"的物品?使用BEGINSWITH或LIKE不起作用,因为列表以其他状态开头.
谢谢!
在iOS 8上,键盘可以达到不同的高度.当用户在键盘之间切换或更改当前键盘的高度时,我该如何检测?
我正在尝试将 CMSampleBufferRefs 附加到 AVAssetWriterInput 并且我不断遇到错误崩溃:
[AVAssetWriterInput appendSampleBuffer:] status 为 0 时无法调用方法
代码:
在视图中加载
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cacheDirectory = [cachePaths firstObject];
NSString *filename = @"test.mp4";
NSString *filePath = [cacheDirectory stringByAppendingPathComponent:filename];
[[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSError *errors;
assetWriter = [[AVAssetWriter alloc] initWithURL:outputURL fileType:(NSString *)kUTTypeMPEG4 error:&errors];
videoWriteInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:outputSettings];
audioWriteInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeAudio outputSettings:audioSettings];
[audioWriteInput addTrackAssociationWithTrackOfInput:videoWriteInput type:AVTrackAssociationTypeTimecode];
audioWriteInput.expectsMediaDataInRealTime = YES;
videoWriteInput.expectsMediaDataInRealTime = YES;
Run Code Online (Sandbox Code Playgroud)
记录功能
-(void)prepareVideo {
if (![assetWriter startWriting]) …Run Code Online (Sandbox Code Playgroud) 我有两个 C 函数:
extern UIColor* LNRandomDarkColor();
extern UIColor* LNRandomLightColor();
Run Code Online (Sandbox Code Playgroud)
作为练习,我尝试将它们作为UIColor.
以下为 WWDC 2016 中 Apple 的“Swift 新增功能”演示示例:
void CGContextFillPath(CGContextRef) NS_SWIFT_NAME(CGContext.fillPath(self:));
Run Code Online (Sandbox Code Playgroud)
我尝试类似地注释我的函数:
extern UIColor* LNRandomDarkColor() NS_SWIFT_NAME(UIColor.randomDarkColor());
extern UIColor* LNRandomLightColor() NS_SWIFT_NAME(UIColor.randomLightColor());
Run Code Online (Sandbox Code Playgroud)
但是我收到以下警告:
'swift_name' 属性只能应用于带有原型的函数声明
我在这里做错了什么?
更新:为此问题打开SR-2999 。
ios ×7
swift ×3
filter ×1
git ×1
ios8 ×1
ipad ×1
iphone ×1
jailbreak ×1
nspredicate ×1
objective-c ×1
recorder ×1
search ×1
springboard ×1
swift3 ×1
uiimage ×1
uikeyboard ×1
uikit ×1
uisearchbar ×1
uitableview ×1
video ×1
xpc ×1