02-iOSプロジェクト点滴-01
1591 ワード
プロジェクトの点滴シリーズ、いくつかのプロジェクトの中の思考と発見、およびいくつかの他のものを記録します.
でmyContainerViewのframeを動的に変更します.
何も言わないで、直接コードに行きます.
1、Masonry iOS 7 crash?
scrollView+autolayoutのレイアウトの問題が解決したと思っていたら、Masonryを楽しく使えました.まさか、UItableviewという穴が待っているとは思わなかった.iOS 7ではtableView自体はautolayoutをサポートしていません.tablviewにsubviewを追加し、制約を追加すると、実行するとcrashになります.問題解決の考え方は簡単です.subViewは追加され、制約は使用されますが、中間viewでsubviewのコンテナ(myContainerViewと呼ばれています)を作り、このmyContainerViewをtableViewに追加する必要があります.myContainerViewはframeを使用してtableViewとの関係を表します.縦横スクリーンを適切に配置するには、viewControllerのライフサイクル方法を覚えておいてください.-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
でmyContainerViewのframeを動的に変更します.
2、UITableView ?
この言葉はいつでも役に立つわけではありません. [cell setSeparatorInset:UIEdgeInsetsZero];
何も言わないで、直接コードに行きます.
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}