How to initialize a custom prototype style table cell in iOS 5 storyboards?

前端 未结 5 1510
悲&欢浪女
悲&欢浪女 2020-12-23 17:01

I am converting over to iOS 5 and storyboards. When I have a table view with default cell style, everything works fine.

- (UITableViewCell *)tableView:(UITab         


        
5条回答
  •  半阙折子戏
    2020-12-23 17:31

    This way

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
        CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    
        return cell;
    }
    

提交回复
热议问题