gpt4 book ai didi

ios - 更新 : Image is captured but will not display

转载 作者:可可西里 更新时间:2023-11-01 04:37:41 25 4
gpt4 key购买 nike

<分区>

我有一些代码可以在我的一个应用程序上运行;所以我复制了代码,进行了必要的更改(即 textField 名称等)并且它有效,除非我将它移动到 UIImageView;没有出现。这是我的代码:

viewController.h(为简洁起见仅显示相关部分)

#import "AppDelegate.h"
#import "Books.h"
#import <AVFoundation/AVFoundation.h>
#import "MBProgressHUD.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <UIKit/UIKit.h>

@class Books;

@interface DetailViewController : UIViewController <UITextFieldDelegate,
UIPopoverControllerDelegate,
UIPickerViewDataSource,
UIPickerViewDelegate,
UIActionSheetDelegate,
UIScrollViewDelegate,
UIImagePickerControllerDelegate,
AVCaptureMetadataOutputObjectsDelegate> {
}

// UIView
@property (strong, nonatomic) IBOutlet UIView *bookDetailView;

// camera stuff
@property (strong, nonatomic) IBOutlet UIImageView *oBookImage;
- (IBAction)bOpenCamera:(UIButton *)sender;

这是相关的 viewController.m 代码:​​

#pragma mark -  Camera stuff
- (IBAction)bOpenCamera:(UIButton *)sender {

if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {

UIImagePickerController *imagePicker = [UIImagePickerController new];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil];
imagePicker.allowsEditing = YES; // MUST HAVE!

[imagePicker setDelegate: (id)self];
[self presentViewController:imagePicker animated:YES completion:nil];
}

}

-(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {

if (error) {
CommonMethods *cm = [CommonMethods new];
[cm displayAlert:@"Warning!" andData:@"Failed to save book image..." andTag:0 andViewController:self];
}
}


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

self.oBookImage.contentMode = UIViewContentModeScaleAspectFill;

NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:NO completion:nil];

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { // (abstract image data)

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

// resize it...
CGRect screenRect = CGRectMake(0, 0, 114.0, 128.0); // was 90.0, 120.0
UIGraphicsBeginImageContext(screenRect.size);
[image drawInRect:screenRect blendMode:kCGBlendModePlusDarker alpha:1];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

oBookImage.image = newImage; // show it...

}
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[self dismissViewControllerAnimated:NO completion:nil];
}

更新:在捕获图像时的某个时刻,我收到此警告:

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

也许与此有关?我试图纠正警告,但无济于事。

我在 Google 和 SO 中寻找过类似的问题,但一无所获。我已经为此工作了两天,决定是时候寻求帮助了。提前致谢。

标准差

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