我不知道tableView
內存分配過程使用reuseIdentifier
static
或不在tableView
delegate
方法。如果我們有數組從方法返回numberOfRowsInSection
方法則多少cell
會在內存中後cellForRowAtIndexPath
方法通過調用一次[UITableViewCell alloc]
alloc
方法進行分配的20計UITableViewCell內存分配
讓猜想。
示例代碼:
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20; // array count
}
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier];
// how many cell will be alloc here
}
// configure cell
}
任何有用的澄清將理解感謝您的時間爲好。
行的高度是多少? – pkc456
@ pkc456'height'由'default'感謝您的時間.. – vaibhav
我試圖添加這個作爲評論,但它太長了。所以請檢查我的[答案](http://stackoverflow.com/a/39406550/988169)。 – pkc456