iOS self.view.window、NSBundle、GCD、delegate、UIVIew setNeedsDisplay、edgesForExtendedLayout、extendedLa

1.  弹出一个对话框,我是用GCD 在当前页面中进行延时弹出,有一次,我在没到延时的时候返回,对话框依旧出现,点击直接崩溃。后来在显示时加入了一个判断给解决了。

if (self.view.window != nil) {//可以判断当前ViewController是否显示

 //your  code

}

2. 我一个小项目里面,是一个TabBar 嵌套了几个NavigationController,在进入下一级页面的时候,需要隐藏Tabbar,我用的是系统自带的,动画都是默认的。

[presentViewController setHidesBottomBarWhenPushed:YES];

3. iOS开发中,基本上都要使用delegate,使用delegate的时候,最好特别的在ViewController的delloc中将delegate赋值为nil,不然有时候会直接闪退,有点类似于野指针的概念,nil接受消息不会有任何问题。

                                 self.delegate = nil;

4. iOS7 中 状态栏的高度是20px,导航栏高度是44px,总共就是64px。

5. iOS7中, UINavigationController中增加一个了可以通过从最左边向右滑动返回上一级ViewController。

@property(nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer NS_AVAILABLE_IOS(7_0);

通过设置interactivePopGestureRecognizer的enable属性可以用来控制是否允许用户右拉返回。

@property(nonatomic, getter=isEnabled) BOOL enabled;  // default is YES. disabled gesture recognizers will not receive touches. when changed to NO the gesture recognizer will be cancelled if it's currently recognizing a gesture

使用方法:    self.navigationController.interactivePopGestureRecognizer.enabled = NO(YES);


6. 通过NSBundle获得资源所在的全路径,我的资源是pointer@2x.png,放在external文件夹下,不是group。有两种方法:


1. NSString *imageFullPath =[[NSBundle mainBundle] pathForResource:@"pointer@2x" ofType:@"png" inDirectory:@"external"];   //注意需要加上@2x,不然找不到


 2. NSString *imageFullPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"external/pointer"]; //不需要加上@2x

真机上的目录是:/var/mobile/Applications/4FE5384E-180D-4875-9771-FB4A734CC012/xxxxx.app/external/pointer

 3. 如果是group的话直接:

    NSString *str=[[NSBundle mainBundle] pathForResource:@“pointer@2x" ofType:@"png"]; //@2x必须的

  真机上的目录是:/var/mobile/Applications/4FE5384E-180D-4875-9771-FB4A734CC012/xxxxx.app/pointer@2x.png


7. UIVIew   setNeedsDisplay 会清空 UIView矩形区域的所有内容


8.iOS7中UIViewController中有一个属性

@property(nonatomic,assign) UIRectEdge edgesForExtendedLayout NS_AVAILABLE_IOS(7_0); // Defaults to UIRectEdgeAll

这个属性是取代了

@property(nonatomic,assign)BOOL wantsFullScreenLayoutNS_DEPRECATED_IOS(3_0,7_0);// Deprecated in 7_0, Replaced by the following(就是上面那个属性):

在iOS 7中,视图控制器都是全屏的四周边缘均延伸,就是说,如果即使视图中上有navigationBar,下有tabBar,那么视图仍会延伸覆盖到四周的区域,这样你原本在iOS6下面放的UIView的frame的(0,0,x,x) 中需要加上64 才能以同样的效果展示在iOS7中。通过设置为UIRectEdgeNone或者UIRectEdgeBottom,这样你就和iOS6下用同样的布局。我测试的时候发现iO7下4s 的 portrait和 landscape下导航栏的高度还不一样。

     注意:这样做会出现一个问题,当你按Home键的时候,然后再重新回到应用时,原来的导航栏会出现黑色不透明,然后才消失。+64还是很靠谱的做法的,不过这样以来苹果以后更新变化也得跟着变化,不太灵活。

     另外,同时新增了几个属性有一个属性是

extendedLayoutIncludesOpaqueBars:

     如果你使用了不透明的操作栏,设置edgesForExtendedLayout的时候也请将extendedLayoutIncludesOpaqueBars的值设置为YES(默认值是NO),在工程刚创建的时候有选择NavBar是否为透明。

Setting this property to YES causes the receiver to block the delivery of  touch events to other views in the same window. The default value of this property is NO. 







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值