我的代码在最后一行给出[__NSMallocBlock__ size]
错误。我尝试使用此类来实现自定义捏合以裁剪图像,但“self.cropView.image =self.image;”行似乎有一些问题。
@interface PECropViewController () <UIActionSheetDelegate>
@property (nonatomic) PECropView *cropView;
@property (nonatomic) UIActionSheet *actionSheet;
@end
@implementation PECropViewController
+ (NSBundle *)bundle
{
static NSBundle *bundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"PEPhotoCropEditor" withExtension:@"bundle"];
bundle = [[NSBundle alloc] initWithURL:bundleURL];
});
return bundle;
}
static inline NSString *PELocalizedString(NSString *key, NSString *comment)
{
return [[PECropViewController bundle] localizedStringForKey:key value:nil table:@"Localizable"];
}
- (void)loadView
{
UIView *contentView = [[UIView alloc] init];
contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
contentView.backgroundColor = [UIColor blackColor];
self.view = contentView;
self.cropView = [[PECropView alloc] initWithFrame:contentView.bounds];
[contentView addSubview:self.cropView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(done:)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *constrainButton = [[UIBarButtonItem alloc] initWithTitle:PELocalizedString(@"Constrain", nil)
style:UIBarButtonItemStyleBordered
target:self
action:@selector(constrain:)];
self.toolbarItems = @[flexibleSpace, constrainButton, flexibleSpace];
self.navigationController.toolbarHidden = NO;
self.cropView.image =self.image;
}