kishikawakatsumi/PEPhotoCropEditor — pull request #28 by brockboland (2014-01-20 18:40:25+00:00)
Title: Only set the toolbar items if they haven't been specified

The `viewDidLoad` method on `PECropViewController` adds the Constrain button to the toolbar. Since this happens right when the view loads, there isn't any way to override it, either to remove the Constrain button or replace it with others.

This change just wraps the `toolbarItems` set in a conditional, so that `toolbarItems` is only changed if it's not already set. In most cases, the Constrain button is shown as it always has been, but now one has the option of setting `toolbarItems` on the controller when it's created.

For example, in the demo app `ViewController.m`, you can now do this (the last line was added):

```objc
- (IBAction)openEditor:(id)sender
{
PECropViewController *controller = [[PECropViewController alloc] init];
controller.delegate = self;
controller.image = self.imageView.image;
// Don't show the Constrain (or any other) toolbar button
controller.toolbarItems = @[];

// Other logic…
}
```

One can also specify other toolbar buttons here if desired.