小编tee*_*ton的帖子

如何使UIImageView正确的帧大小?

我正在尝试使用imagePickerController拍照并在另一个ViewController中的UIImageView中显示图像.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissViewControllerAnimated:YES completion:NULL];
    PAWWallPostCreateViewController *wallPostCreateViewController = [[PAWWallPostCreateViewController alloc] initWithNibName:@"PAWWallPostCreateViewController" bundle:nil];

    wallPostCreateViewController.myImage = info[UIImagePickerControllerEditedImage];
    wallPostCreateViewController.imageView = [[UIImageView alloc] initWithImage:wallPostCreateViewController.myImage];
    wallPostCreateViewController.imageView.contentMode = UIViewContentModeScaleAspectFit;

    NSLog(@"%@",wallPostCreateViewController.imageView); // Output below
    [self.navigationController presentViewController:wallPostCreateViewController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

NSLog中imageView的输出是:

<UIImageView: 0x18f695b0; frame = (0 0; 640 640); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x18f14240>>
Run Code Online (Sandbox Code Playgroud)

框架对我的实际UIImageView来说太大了,它被设置为(60 227; 200 200)

我认为这就是我运行应用程序时根本无法看到UIImageView的原因.我该如何解决?

编辑:

在PAWWallPostCreateViewController.h中

@property (nonatomic, strong) IBOutlet UIImageView *imageView;
Run Code Online (Sandbox Code Playgroud)

我将imageView链接到我的.xib文件

熟悉autoresize = RM + BM的人也是; 因为通常当我使用imagePickerController将UIImage放在同一个视图控制器的UIImageView中时,我的UIImageView数据有一个autoresize = RM + BM; …

objective-c frame uiviewcontroller uiimageview ios

-1
推荐指数
1
解决办法
210
查看次数

标签 统计

frame ×1

ios ×1

objective-c ×1

uiimageview ×1

uiviewcontroller ×1