是什么和<<意思是? [英] What does | and << mean?

查看:199
本文介绍了是什么和<<意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这是一个常见问题,但是我不知道它叫什么,所以我在搜索它时遇到了麻烦.

Sorry if this is a common question but I don't know what it's called so I'm having trouble searching for it.

这是如何工作的:

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

我知道这意味着视图可以同时获得灵活的宽度和高度,但是它如何存储这样的两个变量?

I understand that it means that the view gets both flexible width and height, but how does it store two variables like that?

如果我查看UIViewAutoresizing的typedef,它看起来像:

If i look at the typedef for UIViewAutoresizing it looks like:

enum {
    UIViewAutoresizingNone                 = 0,
    UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
    UIViewAutoresizingFlexibleWidth        = 1 << 1,
...

那么,这样一个变量如何存储一个以上的值?

So, how can one variable store more than one value like this?

推荐答案

"|"是按位或".

<<"也是按位操作转移.它将所有位向左移动:

"<<" is also a bitwise operation shifting. it moves all the bits to the left:

00100 << 1 = 01000

阅读 wiki ,您对或"和移位操作感兴趣.

Read the wiki, you're interested in "or" and shift operations.

这篇关于是什么和&lt;&lt;意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆