有該-heightForRowAtIndexPath
委託方法:
- (CGFloat)heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dict = // get your dictionary for this indexPath
if([[dict valueForKey:@"status"] boolValue] == YES) {
return [[dict valueForKey:@"height"] floatValue];
} else {
return 44.0f;
}
}
我寫了這個代碼assumming你的字典是這樣的:
status -> NSNumber: bool [YES/NO]
height -> NSNumber: float
可以使這個字典中-viewDidLoad
如:
NSNumber *status = [NSNumber numberWithBool:YES]; // or NO
NSNumber *height = [NSNumber numberWithFloat:60.0f]; // or 100.0f, for example
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:status,@"status",height,@"height"];
那麼你可以添加這個字典一些陣列和-heightForRow...
是我的字典也正是這樣的閱讀。但我應該在哪裏申報呢?我的意思是在哪裏和如何?你能告訴我嗎? –
還有一件事......在存儲時我想設置..對於indexpath.row 1的高度是50.0 ..我可以在哪裏做到這一點? –
k..got它kashiv ..感謝兄弟..得到它..我現在做它..一百萬感謝..:D –