UIView 被(显然)莫名其妙地推高

发布于 2024-10-18 17:36:21 字数 1640 浏览 1 评论 0原文

我有一个 UIViews 问题,我真的不知道如何继续。

描述我的问题是徒劳的,所以这里是之前和之后的屏幕截图。 在选择图像后,UIView 会以某种方式获取在 InterfaceBuilder 中定义的布局。在选择图像之前,由于某种原因,它不遵守其定义的布局。

使用 imagePicker 选取图像之前:................................选取图像之后:

之前 | 在此处输入图像描述

所以是的,这基本上就是问题所在。黑色方块是其他图像,您可以通过它应该如何以及不应该如何来判断,其中一张图像正在被剪切(通常位于“无 SIM”标签后面。)我只是将它们放在上面以隐藏真实图像屏幕截图。

所以也许与我在这里做的两件事有关。

  1. 我将所选图像的大小调整为 320-480 并将其放在较小的 UIImageView 上,然后将其上传到服务器。
  2. 如果用户在文本字段上书写,则整个视图都会动画化,因此键盘不会隐藏文本字段。

更新:

我注意到这种情况发生在 UIView 上,它与调整图像或文本字段的大小无关。这也发生在我的 UIView 上,那里只有 3 个按钮和 2 个标签。只有 5 个元素。这 3 个按钮处于带有图像的自定义模式。所以 3 个图像~按钮和 2 个标签...

感谢 Stackoverflowers 同胞的帮助和建议! (叠花者?) 我真的不知道如何继续这里,尽管我一直在尝试在 viewDidLoad 处转换 UIView 但无济于事。

更新2:

我开始认为我用来进行从一个视图到另一个视图的转换的代码可能有问题,并且与其中包含的元素无关。因为除了第一个视图之外,它发生在我所有的视图中。这是我用于视图转换的代码:

- (void) flipToUploadView {

UploadViewController *aUploadView = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil];
[self setUploadViewController:aUploadView];
[aUploadView release];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
[uploadViewController viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController.view removeFromSuperview];
[self.window addSubview:[uploadViewController view]];
[viewController viewDidDisappear:YES];
[uploadViewController viewDidAppear:YES];
[UIView commitAnimations];
}

I have a problem with UIViews to which I really don't know how to proceed.

It will be futile to describe my problem so here are the screenshots of before and after.
Somehow the UIView gets the layout that was defined in interfacebuilder AFTER an image is chosen. Before an image is chosen it doesn't obey to its defined layout for some reason.

Before using imagePicker for picking an image:..........................After Picking image:

Before | enter image description here

So yeah that is basically the problem. The black squares are other images and you can tell by that how it should and how it shouldn't, one of the images is being cut (normally behind the "No SIM" label.) I just put them to hide the real images on the screenshots.

So maybe is something in relation to two things I do here.

  1. I resize the image chosen to 320-480 and put it on a smaller UIImageView before uploading it to a server.
  2. If the user is writing on a textField the entire view is animated up, so the keyboard won't hide the textFields.

UPDATE:

I noticed this happens on a UIView that does nothing related to resizing images or textFields. This is happening too on a UIView I have where there are only 3 buttons and 2 labels. Only 5 elements. The 3 buttons are in custom mode with images. So 3 image~Buttons and 2 labels....

Thank you for your help and suggestions fellow Stackoverflowers!!! (Stackoverflowerers?)
I really have no idea on how to proceed here, though I've been playing around transforming the UIView at the viewDidLoad to no avail.

UPDATE 2:

I started to think that maybe there is something wrong with the code I use to make the transition from view to view and has nothing to do with the elements that are contained in it. Since it is happening in all my views EXCEPT the first view. So here is the code I use for the transition of views:

- (void) flipToUploadView {

UploadViewController *aUploadView = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil];
[self setUploadViewController:aUploadView];
[aUploadView release];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
[uploadViewController viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController.view removeFromSuperview];
[self.window addSubview:[uploadViewController view]];
[viewController viewDidDisappear:YES];
[uploadViewController viewDidAppear:YES];
[UIView commitAnimations];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何必那么矫情 2024-10-25 17:36:21

抱歉,没有足够的声誉来发表评论,但是
两个视图有相同的笔尖吗?
如果没有,是否有可能您只是忘记在 InterfaceBuilder 中模拟状态栏,以获取少数绘制不正确的状态栏?这就是为什么立场不同?

我认为 Tommy 的意思是通常您使用 ModalViewcontroller 来更改视图
[selfpresentModalViewController:uploadViewControlleranimated:YES];
比所有函数调用(willappear、didappear、willdissappear...)都会自动调用
但我认为这不是错误显示的根源

Sorry don't have enough reputation to comment, but
have both views the same nib?
if not, is it possible that you just forgot to simulate the status bar in InterfaceBuilder for the few which is drawn uncorrect? and thats why the positions are different?

And i think what Tommy means is that normally you use the ModalViewcontroller to change views
[self presentModalViewController:uploadViewController animated:YES];
than all the function calls (willappear,didappear,willdissappear...) are called automatically
but i think this is not the source of the wrong displaying

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文