IOS7的蛋疼各類收集

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

ios


ios7基於viewController隱藏狀態條:
經過ViewController重載方法返回枚舉值的方法來控制狀態欄的隱藏和樣式。
首先,須要在Info.plist配置文件中,增長鍵:UIViewControllerBasedStatusBarAppearance,並設置爲YES;
而後,在UIViewController子類中實現如下兩個方法:spa

- (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].code


 UITabBarController的視圖結構變了:(這是由於kpi麼)對象

   -------blog


IOS7的UITableViewCell的定製沒有之前那麼直接了,之前能夠直接繼承UITableViewCell而後drawRect. 可是如今不行了,如今的UITableViewCell包含了一個scrollView,你重繪了UITableViewCell將會被這個scrollView遮住而徹底無法顯示.繼承

以下是一個解決思路:事件

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

{it

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

相關文章
相關標籤/搜索