IOS7的蛋疼各种收集

------------------


ios7基于viewController隐藏状态条:
通过ViewController重载方法返回枚举值的方法来控制状态栏的隐藏和样式。
首先,需要在Info.plist配置文件中,增加键:UIViewControllerBasedStatusBarAppearance,并设置为YES;
然后,在UIViewController子类中实现以下两个方法:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (BOOL)prefersStatusBarHidden
{
    return NO;
}

最后,在需要刷新状态栏样式的时候,调用[self setNeedsStatusBarAppearanceUpdate]方法即可刷新


UILable奇葩的把文字draw到外面去了:
lable在ios7(bate版)下可以draw多行,只要text里有回车,如果你计算出单行text的高度并setFrame之后,对于"1\n2"这样的文本,他的显示就错乱了,1跑上面去了——出了frame区域,解决方法就是setFrame之后调用:[label sizeThatFits:lable.frame.size].


 UITabBarController的视图结构变了:(这是因为kpi么)

   -------


IOS7的UITableViewCell的定制没有以前那么直接了,以前可以直接继承UITableViewCell然后drawRect. 但是现在不行了,现在的UITableViewCell包含了一个scrollView,你重绘了UITableViewCell将会被这个scrollView遮住而完全没法显示.

如下是一个解决思路:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

UITableViewCell * cell = [[[UITableViewCellallocinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:nilautorelease];

UIView * subview = [[[XXView allocinitautorelease];

subview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件

subview.backgroundColor = [UIColorclearColor];// 设为透明从而使得cell.backgroundColor有效.

subview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[cell.contentView addSubview:subview];// cell.contentView是个readonly属性,所以别想着替换contentView了.

return cell;

}


UISearchDisplayController的delegate导致内存问题 
连这个问题都有。。不得不感慨乔布斯死的早啊!
这显示是ios7的(pre-)sdk自己的一个bug,给UISearchDisplayController设置delegate后,在UISearchDisplayController不用了的时候(比如release他之前),务必要setDelegate = nil. 否则可能会出野指针(某已释放的对象)被调用.

self.searchDisplay.delegate = nil

 

 

 

 

 

posted @ 2013-08-29 10:59  小鼬就是我  阅读(6747)  评论(0编辑  收藏  举报