简体   繁体   English

无法移动UIImageView

[英]Unable to move UIImageView

In an XCode iPad application, I use a storyboard with a view and an UIImageView inside, defined in the Interface Builder. 在XCode iPad应用程序中,我使用在Storyboard中带有在Interface Builder中定义的视图和UIImageView。 If I try to change the location of the UIImageView using the SetFrame command [myImageView setFrame:CgRectMake...], the image does not change position on the screen. 如果我尝试使用SetFrame命令[myImageView setFrame:CgRectMake ...]更改UIImageView的位置,则图像不会更改在屏幕上的位置。 Is the setFrame command enough ? setFrame命令足够吗? Thanks. 谢谢。

I would go through a checklist and see that the setup is good: 我将通过一个清单,看看设置是否正确:

  1. Check your IBOutlet - if your UIImageView isn't hooked up, nothing you try calling on it will work. 检查您的IBOutlet-如果未连接UIImageView,则您尝试对其进行的调用都将无效。
  2. Check the autoresize mask - If this is a non-trivial layout where some views are nested within one another, there might be unexpected results. 检查自动调整大小蒙版 -如果这是一种不平凡的布局,其中某些视图相互嵌套,则可能会出现意外结果。
  3. Make sure you're not using Autolayout - This can be done by selecting the storyboard itself and making sure the "Use Autolayout" checkbox within the file inspector (cmd+alt+1) is not ticked (Ticked by default). 确保您没有使用自动版式 -可以通过选择情节提要板本身,并确保未选中文件检查器(cmd + alt + 1)中的“使用自动版式”复选框来完成此操作(默认情况下已选中)。

在此处输入图片说明

我不确定,但是更改位置后是否需要重绘UIImageView,因为这在编程中经常是这种情况?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM