我在使用自定义UITableViewCell的drawRect方法时遇到了麻烦.这是我正在使用的代码
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGPoint origin = _faceView.frame.origin;
CGFloat width = _faceView.frame.size.width;
CGFloat height = _faceView.frame.size.height;
CGFloat border = 2.0f;
CGPoint startPt = CGPointMake(origin.x + width/2, self.frame.size.height);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, startPt.x, startPt.y);
CGPoint basePt = CGPointMake(startPt.x, origin.y - height - border);
CGContextAddLineToPoint(ctx, basePt.x, basePt.y);
CGRect circleRect = CGRectMake(origin.x - border, origin.y - border, width + 2 * border, height + 2 * border);
CGContextAddEllipseInRect(ctx, circleRect);
UIColor *color = [UIColor redColor];
CGContextSetFillColorWithColor(ctx, color.CGColor);
CGContextSetStrokeColorWithColor(ctx, color.CGColor);
CGContextSetLineWidth(ctx, 1.0f);
CGContextDrawPath(ctx, …
Run Code Online (Sandbox Code Playgroud) 我正试图在ios7中获得新的viewController动画,但在尝试使用核心动画时遇到了路障.
我发现在转换完成后,"查看"的控制器似乎没有接收到典型的视图生命周期方法,即viewWillAppear
和viewDidAppear
.我称之为completeTransition:但这样做似乎足够了 - 这是典型的行为吗?或者我做错了什么?这是我的代码:
-(void)executeDismissalAnimation:(id<UIViewControllerContextTransitioning>)transitionContext{
UIView *inView = [transitionContext containerView];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
toViewController.view.hidden = NO;
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[fromViewController.view removeFromSuperview];
[transitionContext completeTransition:YES];
}];
CGFloat duration = 0.4f;
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.values = [self floatValuesFromValue:1.f toValue:1.5f withEasingFunction:ExponentialEaseInOut];
scaleAnimation.duration = duration;
scaleAnimation.fillMode = kCAFillModeForwards;
scaleAnimation.removedOnCompletion = YES;
[fromViewController.view.layer addAnimation:scaleAnimation forKey:nil];
CAKeyframeAnimation *alphaAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
alphaAnimation.values = [self floatValuesFromValue:1.f toValue:0.f withEasingFunction:LinearInterpolation];
alphaAnimation.duration = duration*2;
alphaAnimation.fillMode = kCAFillModeForwards; …
Run Code Online (Sandbox Code Playgroud) 我正在使用自定义UIPresentationController子类来管理UIViewController的表示.我重写- (CGRect)frameOfPresentedViewInContainerView
提供一个从containerView的边界插入的框架.
现在,在对presentViewController进行一些用户操作之后,我想更改presentViewController的框架.我的问题是:有一种'自然'的方法吗?
如何在呈现后调整presentViewController的框架?
不完全确定为什么现在不起作用,我以为它以前一直在工作.有没有人看到这个FetchRequest构造的问题?
- (NSArray *)entriesForDate:(NSDate *)date {
NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"Entry"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY addedOn.unique like %@", [T3Utility identifierForDate:date]];
request.predicate = predicate;
NSError *error = nil;
NSArray *matches = [self.database.managedObjectContext executeFetchRequest:request error:&error];
return matches;
}
Run Code Online (Sandbox Code Playgroud)
再一次,我99%肯定这段代码一直在工作,直到最近,所以我想也许我的代码中某处还有其他东西..但是当我通过调试器运行时,这就是挂起的地方.这是我的错误:
ALL或ANY运算符的左侧必须是NSArray或NSSet
有任何想法吗?
谢谢!
对于熟悉Event Kit的人,我有一个简单的问题...
我正在创建定期提醒,我想在每次重复时发出警报.但是,文档建议我只能创建一个具有绝对日期或相对偏移量的警报.每次提醒重新出现时,有什么方法可以触发警报吗?它会自动执行此操作吗?
谢谢!
我可以使用mailto:作为iTunes Connect中的支持URL吗?
我正在尝试计算UITableViewCell的高度,所以我定义了一个类似于此的类方法
+ (CGFloat)heightWithText:(NSString *)text
{
SizingLabel.text = text;
[SizingLabel sizeThatFits:CGSizeMake(LABEL_WIDTH, CGFLOAT_MAX)];
return (TOP_MARGIN + SizingLabel.frame.size.height + BOTTOM_MARGIN);
}
Run Code Online (Sandbox Code Playgroud)
我已经像这样定义了SizingLabel:
+ (void)initialize
{
SizingLabel = [[UILabel alloc] initWithFrame:CGRectZero];
SizingLabel.numberOfLines = 0;
SizingLabel.lineBreakMode = NSLineBreakByWordWrapping;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我在-heightWithText:方法中粘贴断点,我会注意到SizingLabel的尺寸永远不会改变,因此我得到一个不正确的值.这是为什么?
我有一个NSDates数组,我想从数组中获取最大的NSDate.虽然我总是可以对它们进行排序并抓住第一个/最后一个,但是有没有办法用KeyValueCoding或其他一些快速的单行方式来做到这一点?我知道如果对象有一个日期属性,我可以使用像valueForKeyPath @"@ max.date"这样的东西,但如果对象是日期本身怎么办?
谢谢
我正在经历这种奇怪的效果,在rangeOfString上调用location时它应该返回一个非常大的值,当它不应该...
我的代码看起来像这样:
NSRange range = [string rangeOfString:subString];
NSLog(@"range is %@", NSStringFromRange(range));
Run Code Online (Sandbox Code Playgroud)
这会退出 range is {2147483647, 0}
无法弄清楚为什么.
可能导致此问题的一些事情:
任何帮助非常感谢
这是一些让我感到奇怪的东西:
我正在尝试自动选择selenium ide中的下拉列表,但我无法让它工作.
基本上,我在菜单项上记录了一个单击,显示了下拉菜单,但每当我在其中一个选项上使用click命令时,它会关闭菜单而不选择新选项.我也试过了select命令,但我一直得到"指定元素不是选择"
有任何想法吗?
ios ×9
objective-c ×2
uitableview ×2
xcode ×2
app-store ×1
cocoa-touch ×1
core-data ×1
eventkit ×1
ios7 ×1
iphone ×1
nsdate ×1
nspredicate ×1
nsstring ×1
selenium-ide ×1
uilabel ×1
uiview ×1