首页 \ 问答 \ 如何集中UIView的子视图(How to center a subview of UIView)

如何集中UIView的子视图(How to center a subview of UIView)

我在UIView m中有一个UIView ,我希望内部UIView总是UIView外部UIView中心,而不必调整宽度和高度的大小。

我已经设置了支柱和弹簧,使它在顶部/左/右/底部,而不设置调整大小。 但它仍然不是中心。 任何想法?


I have a UIView inside a UIViewm and I want the inner UIView to be always centered inside the outer one, without it having to resize the width and height.

I've set the struts and springs so that it's on top/left/right/bottom without setting the resize. But it still doesn't center. Any idea?


原文:https://stackoverflow.com/questions/11251988
更新时间:2023-07-21 07:07

最满意答案

Microsoft CRT实现了C11附录K中描述的安全库增强功能。这是规范性的,但不是强制性的。 在K.3.5.2.1节中描述了fopen_s()。 CERT研究所规则FIO06-C也包括在内

问题在于fopen()从简单的时候开始,程序员仍然可以假定他们的程序是唯一操纵文件的程序。 一个从未如此假设的假设。 它没有办法描述如何限制其他进程访问文件,CRT实现传统上在不拒绝任何访问的情况下打开文件。 非标准替代方法已被用于解决这个问题,如_fsopen()

如果文件打开写入,这会产生后果,另一个进程也可以打开该文件进行写入,并且文件内容将被无望破坏。 如果在另一个进程正在写入文件时打开文件进行读取,则文件内容的视图是不可预知的。

fopen_s()通过拒绝所有访问来解决这些问题,如果打开文件进行写入,并且只有在打开文件读取文件时才允许读取访问。


The Microsoft CRT implements the secure library enhancements described in C11 Annex K. Which is normative but not mandatory. fopen_s() is described in section K.3.5.2.1. Also covered by rule FIO06-C of the CERT institute.

At issue is that fopen() dates from simpler times when programmers could still assume that their program was the only one manipulating files. An assumption that has never really been true. It does not have a way to describe how access to the file by other processes is limited, CRT implementations traditionally opened the file without denying any access. Non-standard alternatives have been used to fix this problem, like _fsopen().

This has consequences if the file is opened for writing, another process can also open the file for writing and the file content will be hopelessly corrupted. If the file is opened for reading while another process is writing to it then the view of the file content is unpredictable.

fopen_s() solves these problems by denying all access if the file is opened for writing and only allowing read access when the file is opened for reading.

相关问答

更多
  • 首先,我想说我非常喜欢编译器的警告。 我用-Wall -Wextra调用gcc。 但是,MSVC警告C4996通常会在完全有效的代码上激发。 警告文本中提出的更改通常会严重影响代码的可移植性,但它们从未大幅提高代码质量。 因此,我经常在我的MSVC项目中禁止此警告(项目属性 - > C ++ - >高级 - >禁用特定警告)。 检查这个和那个讨论。 First, I would like to say that I am quite fond of compiler warnings. I invoke g ...
  • Microsoft CRT实现了C11附录K中描述的安全库增强功能。这是规范性的,但不是强制性的。 在K.3.5.2.1节中描述了fopen_s()。 CERT研究所规则FIO06-C也包括在内 。 问题在于fopen()从简单的时候开始,程序员仍然可以假定他们的程序是唯一操纵文件的程序。 一个从未如此假设的假设。 它没有办法描述如何限制其他进程访问文件,CRT实现传统上在不拒绝任何访问的情况下打开文件。 非标准替代方法已被用于解决这个问题,如_fsopen() 。 如果文件打开写入,这会产生后果,另一个进 ...
  • 看起来Microsoft已经弃用了大量使用缓冲区来提高代码安全性的调用。 然而,他们提供的解决方案是不可移植的。 无论如何,如果您不想使用安全版本的电话(如fopen_s ),则需要在包含的头文件之前放置_CRT_SECURE_NO_DEPRECATE的定义。 例如: #define _CRT_SECURE_NO_DEPRECATE #include 预处理器指令也可以添加到项目设置中,以便在项目下的所有文件上实现。 为此,将_CRT_SECURE_NO_DEPRECATE添加到项目属 ...
  • Web上的浅层搜索表明您正在使用已弃用的函数,从而引发错误C4996。 如示例所示,您应该使用函数_wfopen_s。 ... // Create an the xml file in text and Unicode encoding mode. if ((fileHandle = _wfopen( L"_wfopen_test.xml",L"wt+,ccs=UNICODE")) == NULL) // C4996 // Note: _wfopen is deprecated; consider usin ...
  • 这很简单: cl命名空间提供了一个vector类,由于您使用了using namespace cl; ,因此您正在拾取它using namespace cl; 。 删除该行, #include ,删除__NO_STD_VECTOR定义,并简单地使用std::vector , std::vector 。 std::vector做所有需要的东西; 出于某种原因,OpenCL头文件用于提供一个自定义向量类,不应再使用它(我不知道为什么它实际上被 ...
  • 链接器错误基本上告诉boost和OpenCV是使用不同的运行时设置编译的,一个用于静态lib而另一个用于DLL,并且不能混合使用。 您需要重建boost和OpenCV才能使用相同的运行时设置。 The linker error tells basically the boost and the OpenCV were compiled off using different runtime settings, one for static lib and the other for DLL, and can ...
  • gcc不会将弃用警告视为错误。 您可以从avcodec.h中删除'attribute_deprecated'或更改编译器行为。 gcc don't treat deprecation warnings as errors. You can delete 'attribute_deprecated' from avcodec.h or change your compiler behaviour.
  • 快速回答是在对SQLConnectOption的调用周围使用#pragma warning(disable:4996): #pragma warning(push) #pragma warning(disable: 4996) rc = SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); #pragma warning(pop) 更复杂的方法是使用对SQLSetConnectOption的等效调用替换对SQLSetConnect ...
  • 我是上述问题的提问者,如果有人在这里寻找相同问题的答案,那么这是我迄今为止发现的:第1-6点在swift中无效,因为没有预编译器。 (如果真的如此,我希望苹果在我尝试使用-w时会警告我) 如果您确实需要使用已弃用的方法并且不愿意忍受它生成的警告,那么您可以将该代码的一部分作为框架添加,并将您的项目的那部分编译为以前的OS版本。 最好不要使用已弃用的方法! http://www.rockhoppertech.com/blog/swift-framework-creation/ 我希望这对某人有帮助,如果不对, ...
  • 如错误所述,您需要使用fopen_s ,或通过在include之前添加#define _CRT_SECURE_NO_DEPRECATE来禁用安全性异常错误。 这些警告背后的原因,以及如何为各种C运行时功能禁用它们, 在CRT的安全增强中有详细描述。 As the error states, you need to use fopen_s, or disable the security exception errors via adding #define _CRT_SECURE_NO_DEPRECATE ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)