固定UITableViewCell的高度

Pat*_*k R 0 iphone height uitableview

我有一个UITableView,我希望每个单元格都是50px的固定高度,如何在Xcode4中完成?

继承我的tableview,从XIB文件加载

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
Run Code Online (Sandbox Code Playgroud)

Max*_*Max 6

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     return 50;
}
Run Code Online (Sandbox Code Playgroud)