gpt4 book ai didi

ios - 'NSInvalidArgumentException',原因:'-[__ NSMallocBlock__ size]:无法识别的选择器已发送到实例0x2098a5c0'

转载 作者:行者123 更新时间:2023-12-01 16:47:36 34 4
gpt4 key购买 nike

我的代码在最后一行给出了[__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;
}

最佳答案

为图像分配的内存存在问题。未设置self.image中的图像或未正确分配其内存。您可以为图像分配内存:

UIImage* image = [[UIImage alloc] init];

在类似情况下,它对我有帮助。

关于ios - 'NSInvalidArgumentException',原因:'-[__ NSMallocBlock__ size]:无法识别的选择器已发送到实例0x2098a5c0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18721160/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com