IFTTT / FastttCamera

Fasttt and easy camera framework for iOS with customizable filters
http://ifttt.github.io
MIT License
1.86k stars 189 forks source link

Filter image example does not work #31

Closed horaceho closed 9 years ago

horaceho commented 9 years ago

The sample code does not give a preview as expected:

- (void)viewDidLoad {
    [super viewDidLoad];

    _filterCamera = [FastttFilterCamera cameraWithFilterImage:[UIImage imageNamed:@"MonochomeHighContrast"]];
    self.filterCamera.delegate = self;
    [self fastttAddChildViewController:self.filterCamera];
    self.filterCamera.view.frame = self.view.frame;
}

Instead, setting the filterImage once more works:

- (void)viewDidLoad {
    [super viewDidLoad];

    _filterCamera = [FastttFilterCamera cameraWithFilterImage:[UIImage imageNamed:@"MonochomeHighContrast"]];
    self.filterCamera.delegate = self;
    [self fastttAddChildViewController:self.filterCamera];
    self.filterCamera.view.frame = self.view.frame;
    self.filterCamera.filterImage = [UIImage imageNamed:@"MonochomeHighContrast"];
}

Why?

Tested on iPhone 6 Plus, installed via Pod.

lauraskelton commented 9 years ago

@horaceho What do you see with the first method? An unfiltered preview, or a blank preview?

horaceho commented 9 years ago

No preview. It looks like the preview is not there.

lauraskelton commented 9 years ago

@horaceho The given sample code seems to work fine in the demo app and in our apps. Maybe the problem is in the frame setting. Often self.view.frame is still equal to CGRectZero in viewDidLoad, and gets set later, depending on how your view controllers are initialized. If the preview is not appearing at all, perhaps its frame isn't being set correctly, and either using AutoLayout or setting the frame in viewWillAppear would fix the issue.