iOS設(shè)計(jì)模式之工廠模式(簡(jiǎn)單工廠昭雌,工廠方法泪姨,抽象工廠)
簡(jiǎn)單工廠:簡(jiǎn)單工廠模式的工廠類一般是使用靜態(tài)方法专缠,通過接收的參數(shù)的不同來返回不同的對(duì)象實(shí)例瘪板。
工廠方法:定義創(chuàng)建對(duì)象的接口,讓子類決定實(shí)例化哪一個(gè)類揩慕。工廠方法使得一個(gè)類的實(shí)例化延遲到其子類。
工廠方法是針對(duì)每一種產(chǎn)品提供一個(gè)工廠類扮休。通過不同的工廠實(shí)例來創(chuàng)建不同的產(chǎn)品實(shí)例迎卤。在同一等級(jí)結(jié)構(gòu)中,支持增加任意產(chǎn)品玷坠。
抽象工廠:抽象工廠是應(yīng)對(duì)產(chǎn)品族概念的蜗搔。
Cell封頂
-(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
// Remove seperator inset
if([cellrespondsToSelector:@selector(setSeparatorInset:)]) {
[cellsetSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if([cellrespondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cellsetPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if([cellrespondsToSelector:@selector(setLayoutMargins:)]) {
[cellsetLayoutMargins:UIEdgeInsetsZero];
}
}