Tag: ios10

Xcode 8中的自适应布局

我正在开发使用Xcode 8(testing版1)的应用程序。 不幸的是,我无法find“大小类”选项。 在Xcode 7中,有选项“使用大小类”。 但是在Xcode 8中没有这个选项。 在Xcode 8中使用Size Classes或类似的东西有帮助吗?

裁剪CIImage

我有一个类需要一个UIImage ,像这样初始化一个CIImage : workingImage = CIImage.init(image: baseImage!) 然后,图像被用来从中切出9个相邻的正方形,在一个循环中: for x in 0..<3 { for y in 0..<3 { croppingRect = CGRect(x: CGFloat(Double(x) * sideLength + startPointX), y: CGFloat(Double(y) * sideLength + startPointY), width: CGFloat(sideLength), height: CGFloat(sideLength)) let tmpImg = (workingImage?.cropping(to: croppingRect))! } } 这些tmpImgs被插入到一个表中,以后使用,但除此之外, 此代码适用于IOS 9和IOS 10模拟器,但不适用于实际的IOS 10设备 。 生成的图像要么全是空的,要么其中一个就像它应该是的一半,剩下的就是空的。 这不是它应该如何在IOS 10完成吗?

FBSDKLoginManager logInWithReadPermissions:fromViewController:处理程序:完成不调用应用程序第一次运行

我有一个Facebooklogin启用的应用程序,由于某种原因FBSDKLoginManager logInWithReadPermissions: fromViewController: handler:不安装后我的应用程序的第一次运行调用。 如果我只是杀了我的应用程序(即使没有尝试login到Facebook或做任何事情:试图login首先打开或不改变任何东西),并再次打开它,它完美的作品。 为什么? (我已经检查了传递给方法的视图控制器不是零,是当前的视图控制器) 这是我的login代码: +(void)loginWithFacebookWithCompletion:(ULCompletion)completion{ [[[FBSDKLoginManager alloc] init] logInWithReadPermissions:FACEBOOK_READ_PERMISSIONS fromViewController:[ULMasterViewController instance] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if(result.token){ … } […] 剩下的就是不相关的,因为完成块根本不被调用(即使有错误也不会)。 我有硬编码的FACEBOOK_READ_PERMISSIONS : #define FACEBOOK_READ_PERMISSIONS (@[@"user_friends", @"user_birthday", @"email", @"user_photos"]) 最后, [ULMasterViewController instance]是有效的(不为零,并在层次结构中的视图(否则它抱怨视图不在hiearchy,也试过))。

iOS:WKWebView Vs UIWebView

我有一个应用程序/项目与部署目标版本 – iOS 10。 我已经使用了UIWebView ,现在已经废弃,并被WKWebView取代。 所以,我想用我的项目中的WKWebViewreplaceUIWebView。 它迫使我使用UIWebView (iOS 10)或将部署目标更改为iOS 11。 我不能改变部署目标,但作为一个中间件解决scheme,我添加了代码(编程)支持。 我的意思是,如果用户的设备操作系统是iOS 11(或以上),那么使用WKWebView否则使用UIWebView (iOS 10或更低版本)。 问题陈述:故事板的视图控制器不支持这两个版本,我的意思是,在故事板中,如果我将View Controller的部署目标设置为iOS 11,那么应用程序在iOS 10中崩溃(并且应该是明显的),如果我将视图控制器的部署目标设置为iOS 10,那么故事板不允许我build立项目。 对于iOS 10, WKWebView显示我这个错误: Xcode 9 GM – WKWebView NSCoding支持在以前的版本中被破坏 问题:如何让故事板(视图控制器)使用iOS 11的WKWebView和iOS 10的UIWebView ? 故事板(视图控制器)中是否有configuration设置或选项,可以让我添加两个接口?

如何在Core Data中使用fetchRequest谓词

我将联系人标识符从联系人表视图控制器传递到另一个位置表视图控制器。 所以我定义了一个委托ContactSelectionDelegate,并在Location tableview控制器中实现了方法userSelectedContact,并获取contactIdentifierString 我正在search数据库以查找contactIdentifierString的匹配项,并查找另一个属性提供程序名称的值。 这涉及到search整个数据库。 是否有更快的方式分配一个谓词到上下文fetchRequest。 我认为这将是更快,更less的代码行。 有人可以build议如何使用联系fetchRequest谓词? ContactTableViewController代码: protocol ContactSelectionDelegate{ func userSelectedContact(contactIdentifier:NSString) } class ContactTableViewController: UITableViewController { var delegate:ContactSelectionDelegate? = nil override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if (delegate != nil){ let contactDict:NSDictionary = allContacts.object(at: indexPath.row) as! NSDictionary let identifier = contactDict.object(forKey: "uniqueId") delegate!.userSelectedContact(contactIdentifier: identifier as! NSString) self.navigationController!.popViewController(animated: true) } } […]

当iOS 10中的UNUserNotificationCenterDelegate新通知到达时,如何删除先前发送的通知?

这个问题是关于iOS 10中新的UserNotifications框架。 我有一个应用程序,在用户在应用程序中执行特定操作后每半小时安排一次本地通知,从1小时开始。 为了避免混淆用户的locking屏幕或通知中心,我只需要一次显示一条通知,因此只有一条通知包含最新的相关信息。 我的计划是在每次发布新通知时清除所有已发送的通知。 看来这应该是可能的UNUserNotificationCenterDelegate新的willPresent方法,但它不像我所期望的那样。 这里有一个function,我打电话来设置所有的通知,从应用程序中的事件后1小时开始,每半小时安排一次通知,直到事件发生后23.5小时的最后一个通知: func updateNotifications() { for hour in 1…23 { scheduleNotification(withOffsetInHours: Double(hour)) scheduleNotification(withOffsetInHours: Double(hour) + 0.5) } } 这是实际上根据mostRecentEventDate (这是在别处设置的Date安排通知的函数: func scheduleNotification(withOffsetInHours: Double) { // set up a Date for when the notification should fire let offsetInSeconds = 60 * 60 * withOffsetInHours let offsetFireDate = mostRecentEventDate.addingTimeInterval(offsetInSeconds) // set up […]

从容器应用程序和扩展访问核心数据

我正在开发应用程序和共享扩展,并尝试使用核心数据。 但是,当我插入扩展项中的项目,这些项目只在扩展中可见,但不是从容器应用程序(例如,我从应用程序执行NSFetchRequest并获取零项,但在应用程序中,我得到> 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 }() 此外,针对appname.xcdatamodeld的目标成员发货都将同时针对应用和扩展程序进行检查。 如何正确共享容器应用程序和扩展的核心数据?

本地通知不会在ios10中触发

我正在使用UNUserNotificationCenter的ios 10.为了testing,我设置了从当前时间10秒的本地通知。 这是我试过的, – (void)viewDidLoad { [super viewDidLoad]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (!error) { NSLog(@"request succeeded!"); [self set10Notifs]; } }]; } -(void) set10Notifs { if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) { #if XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; [calendar setTimeZone:[NSTimeZone localTimeZone]]; NSDateComponents *components […]

错误:__tcp_connection_write_eof_block_invoke写closurescallback收到错误 – iOS 10

发送XML基本API请求到ONVIF摄像头。 它在ios 9设备上运行正常,但在iOS 10上出现“500内部错误”。 XCode 8控制台打印下面的错误消息: 2016-09-30 12:39:51.295419 VCPlugin[278:10183] [] nw_socket_get_input_frames recvmsg(fd 12, 1024 bytes): [54] Connection reset by peer 2016-09-30 12:39:51.301221 VCPlugin[278:10228] [] nw_socket_write_close shutdown(12, SHUT_WR): [57] Socket is not connected 2016-09-30 12:39:51.301307 VCPlugin[278:10228] [] nw_endpoint_flow_service_writes [3 10.107.2.153:80 ready socket-flow (satisfied)] Write request has 0 frame count, 0 byte count 2016-09-30 12:39:51.301903 VCPlugin[278:10185] [] […]

在iOS 10中的sqlite3_prepare_v2 exc_bad_access

我在我的iOS项目中使用sqlite数据库。 在iOS 9中,所有的东西都是完美的。 现在我已经更新新的Xcode。 但是应用程序在'sqlite3_prepare_v2'上崩溃了很多次。 另外,我不closures数据库加class。 并且只打开一次。 我已经添加数据库打开下面的代码b'acs在debugging我有DBclosures。 但仍然崩溃。 紧急 谁能帮我 ? 提前致谢