将UIView相对于父视图的底部定位?

我怎样才能alignment一个UIView的父母的底部,使框架的Y坐标是相对于屏幕的底部,而不是顶部? 这将等同于在HTML中设置.bottom属性。 这是因为我想确保我的视图总是在窗口的底部而不pipe父级的高度如何。

VoiceOver:强制在屏幕转换后select一个辅助function元素

我正在使我的iOS应用程序可访问,我快要完成了。 我的应用程序包含多个自定义屏幕转换,当VoiceOver处于打开状态时,它似乎select在转换之后描述的最左上angular的元素,或偶尔select一个随机元素。 UIAccessibilityTraitSummaryElement看起来很有希望,但据我所知,它只适用于应用程序启动,而不是任意过渡后。 似乎没有可访问性特征或属性来指定给予VoiceOver焦点的元素的首选顺序。 有什么办法强制VoiceOver的重点?

iOS 7.0和ARC:UITableView从未在行animation之后解除分配

我有一个非常简单的testing应用程序与ARC。 其中一个视图控制器包含UITableView。 在做animation之后( insertRowsAtIndexPaths或者deleteRowsAtIndexPaths ),UITableView(和所有的单元格)永远不会被释放。 如果我使用reloadData ,它工作正常。 iOS 6没有问题,只有iOS 7.0。 任何想法如何解决这个内存泄漏? -(void)expand { expanded = !expanded; NSArray* paths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0],nil]; if (expanded) { //[table_view reloadData]; [table_view insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationMiddle]; } else { //[table_view reloadData]; [table_view deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationMiddle]; } } -(int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return expanded ? 2 : 0; } […]

iOS 11search栏跳转到屏幕顶部

我有一个UITableView,我把它的标题设置为一个search栏。 tableView.tableHeaderView = searchController.searchBar 一切工作按计划,直到你点击它,它似乎从tableView分离并跳转到屏幕的顶部。 tableView行留在原地。 任何理由会在iOS 11而不是iOS 10中做到这一点?

RegEx在Swift中?

我正在学习斯威夫特,而我有(另一个)问题。 Swift中是否有正则expression式?如果是的话,我该如何使用它们? 在我的研究中,我发现了一些矛盾的信息。 苹果开发者文档有一些提到正则expression式,但它看起来不像我见过的任何其他语言。 如果这是解决scheme,我该如何使用它? 另一方面, 这个网站表明RegEx在Swift中不存在。 它是否正确? 如果有帮助,我试图使用正则expression式来获取包含价格的JSON风格API的平均比特币价格,但也有很多我不想要的东西。 对不起,另一个基本问题。

iOS 9中的HTTPS请求:NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9802)

我正在更新我的应用程序,以适应苹果的新ATS 。 在没有对Plist-Info进行任何更改的情况下,以下代码会在香草iOS 9模拟器的sendSynchronousRequest()方法中引发错误。 NSURL *url =[NSURL URLWithString:@"https://Google.com"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init]; [request setHTTPMethod:@"GET"]; [request setURL:url]; NSURLResponse *urlResponse = nil; NSError *error = nil; NSData *reponse = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]; 错误: NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9802) 有什么想法可能是在这个问题背后? Ps :我知道NSURLConnection已经被弃用了。 但是这个调用的工作原理是在Plist中添加AllowArbitraryLoads。

在UITextField的光标位置插入string

我在UITableView中有几个UITextFields。 用户应该只能插入数字和点。 为此,我将键盘types设置为UIKeyboardTypeNumberPad,并在左下angular添加了一个“。”button。 每次按下button,都会调用一个函数。 这个函数应该在当前的光标位置插入一个点,但是这是个问题:UITextField没有一个selectedRange属性,所以我不能获取当前的光标位置。 有谁知道如何解决这个问题,或者有没有其他的方法来做到这一点? 谢谢。

本地通知“didReceiveLocalNotification”调用两次

我正在处理本地通知使用: – (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif 并安排本地通知: – (void)scheduleNotificationWithInterval:(int)minutesBefore { UILocalNotification *localNotif = [[UILocalNotification alloc] init]; if (localNotif == nil) return; NSDate *fireDate = [NSDate date]; localNotif.fireDate = [fireDate dateByAddingTimeInterval:minutesBefore*60]; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.repeatInterval = kCFCalendarUnitMinute; localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"LocalEvent notification in %i minutes.", nil),minutesBefore]; localNotif.alertAction = NSLocalizedString(@"View Details", nil); localNotif.applicationIconBadgeNumber = 1; NSDictionary […]

如何在GMSMapView中获取animation折线路线,以便在地图移动时与地图一起移动?

我已经通过下面的代码创build了像CAShapeLayer这样的animation折线,我已经将CAShapeLayer作为子图层添加到GMSMapiew中,但是如果我移动地图,图层将不会移动。 在哪里添加图层,让它随着地图一起移动? func layer(from path: GMSPath) -> CAShapeLayer { let breizerPath = UIBezierPath() let firstCoordinate: CLLocationCoordinate2D = path.coordinate(at: 0) breizerPath.move(to: self.mapView.projection.point(for: firstCoordinate)) for i in 1 ..< Int((path.count())){ print(path.coordinate(at: UInt(i))) let coordinate: CLLocationCoordinate2D = path.coordinate(at: UInt(i)) breizerPath.addLine(to: self.mapView.projection.point(for: coordinate)) } let shapeLayer = CAShapeLayer() shapeLayer.path = breizerPath.reversing().cgPath shapeLayer.strokeColor = UIColor.green.cgColor shapeLayer.lineWidth = 4.0 shapeLayer.fillColor = […]

NSUserDefaultsDidChangeNotification和Today Extensions

我正在开发一个带有Today Extension的iPhone应用程序。 该应用程序有一个模型模块,从/加载到NSUserDefaults。 由于我希望这个信息可以被主应用程序和扩展使用,我使用一个应用程序组: let storage = NSUserDefaults(suiteName: "group.etc.etc.etc…") 应用程序和扩展程序都可以访问信息,没有任何问题。 主应用程序偶尔会创build一个本地通知来呈现给用户。 该通知有两个与之相关的操作(UIUserNotificationAction)。 其中一个动作触发主应用程序的背景上运行一些代码。 该代码更改NSUserDefaults信息并触发同步。 我的代码是这样的: func application(application: UIApplication, handleActionWithIdentifier id: String?, forLocalNotification not: UILocalNotification, completionHandler: () -> ()) { // Interact with model here // New information gets saved to NSUserDefaults userDefaultsStorage.synchronize() completionHandler() } 现在,在今天分机。 我自然地观察到对NSUserDefaults上的信息所做的任何更改,以便我可以重新加载小部件上的接口: override func viewDidLoad() { super.viewDidLoad() // … NSNotificationCenter.defaultCenter().addObserverForName(NSUserDefaultsDidChangeNotification, object: […]