枚举的定义还支持位运算的方式定义,如下:
等于号后面必须等于1
- typedef NS_ENUM(NSInteger, Test)
- {
- TestA = 1, //1 1 1
- TestB = 1 << 1, //2 2 10 转换成 10进制 2
- TestC = 1 << 2, //4 3 100 转换成 10进制 4
- TestD = 1 << 3, //8 4 1000 转换成 10进制 8
- TestE = 1 << 4 //16 5 10000 转换成 10进制 16
- };
5、动态加载xib?
答:self.view = [[[NSBundle mainBundle]loadNibNamed:@"RecommednViewController" owner:self options:nil]lastObject]; 同时需要关联xib为该controller
6、if else 与 switch case 区别??
答:if-else结构中,条件判断部分可以是任何符合语法的表达式。switch-case结构中,switch括号中以及case右边的表达式必须是常量表达式。如果条件判断所用的表达式并非常量,那么不能用switch-case,只能用if-else。
7、GoogleMaps常用的类?
答: GMSCameraPosition (确定即将呈现地图的位置)
GMSMapView (地图视图)
GMSMapViewDelegate (代理)
GMSMutablePath (点与点之间的路径)
GMSPolyline (呈现路径的线条)
GMSMarker (地图上的小icon)
CLLocationDegrees (封装坐标点)
CLLocation (坐标)
CLGeocoder (通过坐标来进行城市解码)
CLPlacemark (储存的城市信息)
CLLocationManager
8、RunLoop 的使用,如何阻塞当前线程??
答:NSRunLoop * asyRunLoop=[NSRunLoop currentRunLoop];
while (pause)
{
[asyRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
9、iOS autoresizingMask与autoLayout的区别?
答:autoresizingMask是子视图的左、右、上、下边距以及宽度和高度相对于父视图按比例变化
UIViewAutoresizingNone (不自动调整)
autoLayout是子视图相对于某个视图(可以是父视图也可以是同级兄弟视图)的位置,在屏
幕尺寸发生变化时,相对位置保持不变
//在页面水平居中显示按钮。
[self.viewaddConstraint: [NSLayoutConstraintconstraintWithItem:self.btn
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0]];
10、如何实现微信摇一摇功能?
答:AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:NULL];
player=[[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:nil];
[player prepareToPlay];
player.volume = .8;
[player play];
11、图片移动的动画效果?
答://让imagdown上下移动
CABasicAnimation *translation = [CABasicAnimation animationWithKeyPath:@"position"];
translation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
translation.fromValue = [NSValue valueWithCGPoint:CGPointMake(160, 345)];
translation.toValue = [NSValue valueWithCGPoint:CGPointMake(160, 420)];
translation.duration = 0.5;
translation.repeatCount = 1;
translation.autoreverses = YES;
[_imgDown.layer addAnimation:translation forKey:@"translation"];
11、如何适配IOS6.0 和IOS7.0 ,以及3.5inch 和4.0inch的屏幕?
答:
方法一:
int width = [[UIScreen mainScreen] bounds].size.width;
int height = [[UIScreen mainScreen] bounds].size.height;
if (IOS7_EARLY) {
_myTabelview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 , width , height - 64 - 49 ) style:UITableViewStyleGrouped];
}
else
_myTabelview = [[UITableView alloc] initWithFrame:CGRectMake(0, 64 , width , height - 64 -49) style:UITableViewStyleGrouped];
方法二:
UIView *bgView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
if (IOS7_EARLY) {
_myTabelview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 , 320, CGRectGetHeight(bgView.frame)- 64 - 49 ) style:UITableViewStyleGrouped];
}
else
_myTabelview = [[UITableView alloc] initWithFrame:CGRectMake(0, 64 , 320, CGRectGetHeight(bgView.frame) - 64 -49) style:UITableViewStyleGrouped];
12、静态方法和实例化方法的区别??
答: 从线程安全、性能、兼容性上来看 也是选用实例化方法为宜。
早期的结构化编程,几乎所有的方法都是“静态方法”,引入实例化方法概念是面向对象概念出现以后的事情了,区分静态方法和实例化方法不能单单从性能上去理解,创建c++,java,c#这样面向对象语言的大师引入实例化方法一定不是要解决什么性能、内存的问题,而是为了让开发更加模式化、面向对象化。这样说的话,静态方法和实例化方式的区分是为了解决模式的问题。
拿别人一个例子说事:
比如说“人”这个类,每个人都有姓名、年龄、性别、身高等,这些属性就应该是非静态的,因为每个人都的这些属性都不相同;但人在生物学上属于哪个门哪个纲哪个目等,这个属性是属于整个人类,所以就应该是静态的——它不依赖与某个特定的人,不会有某个人是“脊椎动物门哺乳动物纲灵长目”而某个人却是“偶蹄目”的。
http://blog.csdn.net/biaobiaoqi/article/details/6732117
13、如何一次性将NSLog语句移除?
答:在-Prefix.pch文件中加入以下代码:
#ifdef DEBUG
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...) /* */
#endif
#define ALog(...) NSLog(__VA_ARGS__)
14、typedef void (*comm_callback)(char*, int, void*); 是什么意思 ?
答:定义一个函数指针类型comm_callback
这个函数类型是这样:返回值void 参数:char*,int,void*
可以直接使用comm_callback定义一个函数指针
如:comm_callback pFun;
http://modernrobber.blog.163.com/blog/static/214636320071125112629565/
http://blog.csdn.net/u011344883/article/details/25103383 (函数指针右左法则)
15、双向链表是怎样的?
答:线性表的双向链表存储结构
typedef struct DuLNode
{
ElemType data;
struct DuLNode *prior,*next;
}DuLNode,*DuLinkList;