Tag: cocoa触摸

使UIAlertView阻塞

我需要使UIAlertView阻止。 因为我有function,我需要返回UIAlertViewselect。 但问题是,显示UIAlertView后,我的function代码进一步执行,所以我不能捕获UIAlertViewselect(我可以在委托方法,但我需要返回函数结果)。 我试图用NSCondition使UIAlertVIew阻塞。 但代码不起作用。 condition = [NSCondition new]; result = 0 ; [condition lock]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fingerprint" message:@"test" delegate:window_self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil]; [alert setDelegate:self]; [alert show]; while (result == 0) [condition wait]; [condition unlock] ; – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { [condition lock] ; if (buttonIndex == 0) { result = 2; } […]

如何使用Core Graphics绘制点?

我在Quartz中看到绘制线条和圆圈的API。 但是我想要做的就是指定(x,y)笛卡尔坐标来给像素着色一个特定的值。 我怎么做?

UIControlEventTouchDragExit在距离UIButton 100像素时触发

目前, UIControlEventTouchDragExit只会在我从button拖动100个像素的时候触发。 我想定制这种行为,并把这个范围在25像素左右,但我相对较新的编程,并从来没有需要重写/定制这样的内置方法。 我已经读过一些其他post,我需要UIButton (或者甚至UIControl ?),并覆盖-(BOOL) beginTrackingWithTouch: (UITouch *) touch withEvent: (UIEvent *) event和相关的方法,但我真的不知道从哪里开始这样做。 任何人都可以提供一些build议,我可以做到这一点? 非常感激! ^ _ ^

UITableView与有限的滚动和延迟加载

我得到了一个UITableView充满了未知数量的行。 每行包含(例如3个)图像,应用程序从web服务收集这些信息。 对于UITableView我实现了无限滚动。 每当表几乎到达当前的行数的末尾,我发起一个调用web服务,以获取接下来的50行数据。 我在由UITableView调用的scrollViewDidScroll方法中执行此操作。 – (void) scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat actualPosition = scrollView.contentOffset.y; float bottomOffset = 450; if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) bottomOffset = 1000; CGFloat contentHeight = scrollView.contentSize.height – bottomOffset; if (actualPosition >= contentHeight && !_loading && !_cantLoadMore) { self.loading = YES; _currentPage++; NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; [dict setObject:[NSNumber numberWithInt:_currentPage] forKey:@"page"]; [dict […]

在Swift子类中添加便捷初始化器

作为一个学习练习,我试图实现一个SKShapeNode的子类,它提供了一个新的方便初始值设定项,它使用一个数字并构造一个数字宽度和高度的正方形的ShapeNode。 根据Swift书 : 规则1 如果你的子类没有定义任何指定的初始值设定项,它将自动inheritance它的所有超类指定的初始值设定项。 规则2 如果你的子类提供了它所有超类指定的初始化方法的实现,或者按照规则1inheritance它们,或者提供一个自定义实现作为其定义的一部分,那么它将自动inheritance所有的超类方便初始化方法。 但是,下面的类不起作用: class MyShapeNode : SKShapeNode { convenience init(squareOfSize value: CGFloat) { self.init(rectOfSize: CGSizeMake(value, value)) } } 相反,我得到: Playground execution failed: error: <REPL>:34:9: error: use of 'self' in delegating initializer before self.init is called self.init(rectOfSize: CGSizeMake(value, value)) ^ <REPL>:34:14: error: use of 'self' in delegating initializer before self.init is […]

每天在特定时间快速重复本地通知

我是iOS开发新手,但已经创build了应用程序,我正在尝试创build一个设置时间的每日通知。 目前通知对于给定的date/时间执行一次。 我不确定如何使用repeatInterval方法每天安排。 每天重复通知的最佳方法是什么? 任何帮助将不胜感激(Y)。 var dateComp:NSDateComponents = NSDateComponents() dateComp.year = 2015; dateComp.month = 06; dateComp.day = 03; dateComp.hour = 12; dateComp.minute = 55; dateComp.timeZone = NSTimeZone.systemTimeZone() var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! var date:NSDate = calender.dateFromComponents(dateComp)! var notification:UILocalNotification = UILocalNotification() notification.category = "Daily Quote" notification.alertBody = quoteBook.randomQuote() notification.fireDate = date notification.repeatInterval = UIApplication.sharedApplication().scheduleLocalNotification(notification)

查找UIAlertView而不参考它iOS 7

我在我的项目中使用的代码片段在这里回答: UIAlertView没有引用它 代码如下: + (UIAlertView *) getUIAlertViewIfShown { if ([[[UIApplication sharedApplication] windows] count] == 1) { return nil; } UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; if ([window.subviews count] > 0) { UIView *view = [window.subviews objectAtIndex:0]; if ([view isKindOfClass:[UIAlertView class]]) { return (UIAlertView *) view; } } return nil; } 不幸的是,它不适用于iOS 7,我无法解雇一个警报视图。 在debugging过程中,我发现在循环中显示的是UITransitionView类。 很混乱,因为我找不到这个视图类的快速文档。 […]

如何将UIColor值转换为指定的颜色string?

我需要将UIColor转换为颜色名称的NSString 。 我试过了: NSString *colorString = NSStringFromClass([[UIColor redColor] class]); 但colorString没有给@“redColor”。

带有“循环”滚动的UIScrollView

我正在尝试在我的UIScrollView中使“循环”滚动,但不成功。 我想做什么:如果uiscrollview到达结束,它应该移动到开始,如果uiscrollview在开始和移回来,它应该移动到结束 添加滚动视图是不好的方式在我的情况(其他方法应该得到“页面ID”) 你有什么想法吗?

如何在Swift中获得UIScrollView的垂直方向?

如何在VC中上下滚动/滑动方向? 我想在我的VC中添加一个UIScrollView或其他东西,可以看到用户滑动/向上或向下滑动,然后隐藏/显示一个UIView这取决于它是一个向上/向下的手势。