我正在开发一个Cocoa应用程序,并遇到突出显示的问题.MAC OS X应用程序中的标准突出显示颜色为蓝色,但它不适合我的应用程序,因为由于设计概念,我需要绿色来突出显示.
我试图继承NSTableview和覆盖方法
- (void)highlightSelectionInClipRect:(NSRect)clipRect
Run Code Online (Sandbox Code Playgroud)
但它没有帮助.
如何解决这个问题?
1)我有一个任务来呈现和解除带有自定义动画的模态UIViewController.
2)自定义动画是更改alpha并移动一个子元素
3)我创建FadeInAnimationController和FadeOutAnimationController类实现 UIViewControllerAnimatedTransitioning如下:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
// obtain state from the context
CIToViewController *toViewController = (CIToViewController *)[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// obtain the container view
UIView *containerView = [transitionContext containerView];
// set the intial state
toViewController.view.alpha = 0.0f;
toViewController.elementBottomPosition.constant -= 20.0f;
[toViewController.view layoutIfNeeded];
// add the view
[containerView addSubview:toViewController.view];
// animate
[UIView animateWithDuration:[self transitionDuration:transitionContext]
animations:^{
toViewController.view.alpha = 1.0f;
toViewController.elementBottomPosition.constant += 20.0f;
[toViewController.view layoutIfNeeded];
}
completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
Run Code Online (Sandbox Code Playgroud)
4)elementBottomPosition是NSLayoutConstraint,它适用于Present动画
5)问题: …
我正在开发一些iOS应用程序,我需要做一些相机扫描.这是我第一次使用AVFoundation,之前我使用UIImagePickerController开发了相机应用程序,但AVFoundation似乎更强大.
问题是它会切断预览图层中的边缘,无论我将预览图层的边框设置为视图控制器的边框.
这是我的代码:
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *photoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:photoCaptureDevice error:&error];
if(videoInput){
[captureSession addInput:videoInput];
[captureSession startRunning];
NSLog(@"ok");
}
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
previewLayer.frame = self.view.bounds;
NSLog(@"%f %f", previewLayer.frame.size.width, previewLayer.frame.size.height);
[self.view.layer addSublayer:previewLayer];
Run Code Online (Sandbox Code Playgroud)
非常感谢帮助,Artem
在我的应用程序中,我需要以编程方式在日历中创建一个事件,所有算法都围绕方法创建的日期工作+ (id)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds.但是使用这种方法我无法创建一个事件,似乎它没有在某个地方设置时区,因为使用其他方法(即[NSDate date])成功创建了事件.
我的解决方案是转换NSDate为CFGregorianDate,设置时区并转换回来.我想这似乎有点长.
代码段:
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1322045010]; // interval is in seconds
NSLog(@"%@", date);
event.title = @"Test";
event.startDate = date;
event.endDate = date;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
[event addAlarm:[EKAlarm alarmWithAbsoluteDate:date]];
[eventStore saveEvent:event span:EKSpanThisEvent error:nil];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是 - 为什么不能创建一个NSDate初始化的事件+ (id)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds?如果有人建议更有力的方法来解决这个问题,我将非常感激.
阿尔乔姆
ios ×3
animation ×1
autolayout ×1
cocoa ×1
cocoa-touch ×1
highlighting ×1
iphone ×1
nstableview ×1
objective-c ×1