¿La subclasificación de UITableViewCell da como resultado un error en el guión gráfico?
Frecuentes
Visto 277 veces
1
I have a strange error that is happening when I attempt to run my project. I am redesigning my old setup, which was a dedicated UITableViewController. I am moving that into a standard UIViewController with a UITableView inside of it.
Estoy recibiendo este error:
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool failed with exit code 255
I narrowed down exactly what is causing it, but I have no idea why. It happens when I attempt to set the UITableViewCell within the tableview to be a custom UITableViewCell class that I created. Keep in mind that I used the exact same setup for my original UITableViewController. Why is the build failing with a Storyboard compiler error because I set the UITableViewCell to be a custom subclass?
EDIT 1 to add relevant code:
.h
@interface SingleCodeViewController : UIViewController <GADBannerViewDelegate, UITableViewDelegate>
@end
.m
@interface SingleCodeViewController ()
// Connected to the table view in IB
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
@implementation SingleCodeViewController
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 30)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 300, 30)];
switch (section) {
case 0:
label.text = @"Date";
break;
case 1:
label.text = @"Rate";
break;
default:
break;
}
label.font = [UIFont boldSystemFontOfSize:17];
label.shadowColor = [UIColor blackColor];
label.shadowOffset = CGSizeMake(1.0, 1.0);
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[view addSubview:label];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30.0;
}
// Sets the background for each static cell to be the same custom cell as the table view's.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell isKindOfClass:[CodeCellTVC class]]) {
if (![cell.backgroundView isKindOfClass:[CustomCellBackground class]]) {
cell.backgroundView = [[CustomCellBackground alloc] init];
}
}
}
@end
My custom UITableViewCell class:
.h
@interface CodeCellTVC : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *codeTableLabel;
@end
.m
// Empty implementation
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas iphone ios objective-c uitableview or haz tu propia pregunta.
Are you sure that everything is linked up properly. Meaning all connections are made between the controller and your
UITableViewCell
. Also, can you please add relevant code? - Evan Stoddard@EvanStoddard I am doing the view strictly in IB. So setting the custom class for the UITableViewCell is done there as well. I added some relevant code that is apart of the connected UIVieController. - BlueBear
The class that you are trying to link your
UITableViewCell
to is not a subclass of theUITableViewCell
class so therefore it will crash. - Evan Stoddard@EvanStoddard That code is for the entire UIViewController. I have added code to the specific UITableViewCell class that I am attempting to link my cell's to. - BlueBear
Yes but you need make your view controller a
UITableViewDelegate
yUITableViewDataSource
- Evan Stoddard