小编Ton*_*riz的帖子

UIKeyboard建议iOS 8通知的高度?

我试图在iOS 8中保持一个文本字段位于键盘顶部.但是当用户向上或向下滑动键盘顶部以显示或消除iOS 8字建议时,我需要通知新的高度键盘,所以我可以向上或向下移动文本字段的高度.

我怎么能做到这一点?

谢谢!

uikeyboard nsnotificationcenter ios ios8

6
推荐指数
1
解决办法
3370
查看次数

在iOS上使用AVCaptureSession加载相机的速度很慢 - 如何加快速度?

现在我试图允许用户在我的应用程序中拍照而不使用UIImagePickerController.我正在使用AVCaptureSession和所有相关的类来加载相机提要作为我在其中一个视图控制器上的全屏视图的子图层.代码可以工作,但遗憾的是相机加载速度很慢.通常需要2-3秒.这是我的代码:

session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;

if ([session canSetSessionPreset:AVCaptureSessionPresetHigh])
    //Check size based configs are supported before setting them
    [session setSessionPreset:AVCaptureSessionPresetHigh];

[session setSessionPreset:AVCaptureSessionPreset1280x720];

CALayer *viewLayer = self.liveCameraFeed.layer;
//NSLog(@"viewLayer = %@", viewLayer);

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

captureVideoPreviewLayer.frame = viewLayer.bounds;
[viewLayer addSublayer:captureVideoPreviewLayer];

AVCaptureDevice *device;

if(isFront)
{
    device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
}
else
{
    device = [self frontCamera];
}

AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureDeviceInput * audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:nil];
[session addInput:audioInput];

NSError *error = nil;
input = …
Run Code Online (Sandbox Code Playgroud)

camera photo ios avcapturesession

5
推荐指数
3
解决办法
7035
查看次数

向NSAttributedString添加常规操作?

我只是想在我的UILabel中使用NSAttributedString添加一个objetive-c动作来调用某个范围.

但我不知道该怎么做.我不想打开URL,我只是想调用一个方法.

谢谢

nsattributedstring uilabel ios

3
推荐指数
1
解决办法
4243
查看次数

是否可以在保留计数不为零的对象上调用dealloc?

我将保持这个简短明了:我有一个对象的dealloc方法被调用.我还每3秒调用一次NSTimer来记录控制所述对象的当前保留计数.

需要明确的是:我知道NSTimer将保留该对象.即使考虑到这一点,情况仍然没有加起来.

无论如何 - 在这个计时器触发时,对象的保留计数被记录为3.这让我感到困惑有两个原因:

  1. 如果对象的保留计数未达到0,为什么要调用dealloc?
  2. 由于dealloc被调用,所以至少,自NSTimer实例保留它以来,保留计数至少应为1?

任何帮助是极大的赞赏.谢谢.

编辑:代码:

[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(logRetainCount) userInfo:nil repeats:YES];
Run Code Online (Sandbox Code Playgroud)

^在viewDidLoad中设置

- (void)logRetainCount
{
    NSLog(@"own retain count: %ld", CFGetRetainCount((__bridge CFTypeRef)self));
}
Run Code Online (Sandbox Code Playgroud)

^日志保留计数的方法

- (void)dealloc {
    NSLog(@"view controller deallocated");
}
Run Code Online (Sandbox Code Playgroud)

^ dealloc方法在VC中实现,应该被解除分配

和控制台输出:

自己保留计数:5

视图控制器已取消分配

自己保留计数:3

objective-c dealloc ios automatic-ref-counting

2
推荐指数
1
解决办法
341
查看次数

当由于ARC中的保留计数为0而释放视图控制器或任何对象时,是否有提醒的方法?

曾经是dealloc但是因为ARC已经消失了.

我需要一些方法来确切地告知对象何时被释放(我宁愿不使用乐器,因为它真的很慢而且现在不适合我.)

ios automatic-ref-counting

0
推荐指数
1
解决办法
16
查看次数

@ try @ catch块没有捕获内部异常

好的,我以前从未见过这个.这是我的代码:

    @try {
        [self.avPlayer removeObserver:self forKeyPath:@"status"];
        [self.avPlayer removeObserver:self forKeyPath:@"rate"];
    } @catch (NSException *exception) {

    } @finally {

    }
Run Code Online (Sandbox Code Playgroud)

您可以清楚地看到,我在@try块中有这两行代码.但是,它仍然会崩溃我的应用程序.这是未捕获的异常消息:

无法从<AVPlayer 0x7fa8d714ad70>中删除观察者<SoulHLECellView 0x7fa8d2b536b0>作为关键路径"status",因为它未注册为观察者.

所以,非常清楚,这是由我上面发布的代码引起的.这怎么可能?我在这里错过了什么?

objective-c objective-c-runtime ios objective-c-blocks

0
推荐指数
1
解决办法
1086
查看次数