叠加背景检查

时间:2014-07-18 23:44:14

标签: ios objective-c background uiimagepickercontroller

我在我的应用中使用UIImagePickerViewController的自定义叠加层。

默认情况下,它设置为点按UIButton

来录制视频

如果我关闭应用程序,然后稍后重新打开它,UIButton在我点按时就不会开始录制。

有关解决此事的任何建议吗?

编辑:

关闭应用程序,我的意思是按主页按钮,以便应用程序在后台。

当我重新打开应用程序时,通过点击图标,开始录制视频的按钮不起作用。

编辑2:

UIButton位于Interface Builder中。我把它连接到了行动。

这是我的行动代码......

- (IBAction)shutterButtonPressed:(id)sender
{
    if ([self.cameraButton.imageView.image isEqual:[UIImage imageNamed:@"camera"]])
    {
        [self.pickerReference takePicture];
    }
    else
    {
        if ([self.cameraButton.imageView.image isEqual:[UIImage imageNamed:@"video"]])
        {
            if (isRecording)
            {
                [self.pickerReference stopVideoCapture];
                NSLog(@"video capture has stopped");

                [self.shutterButton setImage:[UIImage imageNamed:@"shutter_record"] forState:UIControlStateNormal];
                [self.shutterButton setImage:[UIImage imageNamed:@"shutterHighlighted"] forState:UIControlStateHighlighted];

                isRecording = NO;
                self.settingsButton.userInteractionEnabled = YES;
                self.cameraButton.userInteractionEnabled = YES;

                [self.timer invalidate];
                self.timer = nil;
                self.recordTimeLabel.text = @"00:00:00";
            }
            else
            {
                [self.pickerReference startVideoCapture];
                NSLog(@"video capture has started");

                [self.shutterButton setImage:[UIImage imageNamed:@"shutter_record_stop"] forState:UIControlStateNormal];
                [self.shutterButton setImage:[UIImage imageNamed:@"shutterHighlighted"] forState:UIControlStateHighlighted];

                isRecording = YES;
                self.settingsButton.userInteractionEnabled = NO;
                self.cameraButton.userInteractionEnabled = NO;

                self.startDate = [NSDate date];
                self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];

                self.pickerReference.videoMaximumDuration = 600;
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您不应通过比较image中包含的UIImageView来决定采取哪种行动。您无法保证[UIImage imageNamed:@"whatever"]每次都会返回完全相同的对象。定义一个BOOL标记,例如isCamera,在更新imageView的{​​{1}}的同时更新它,然后检查此标记。