Ich habe eine benutzerdefinierte UITableViewCell, EventCell
genannt.Benutzerdefiniert UITableViewCell nicht aufrufen PreparateForSegue
EventCell.h
#import <UIKit/UIKit.h>
@interface EventCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
@property (nonatomic, strong) IBOutlet UILabel *locationLabel;
@property (nonatomic, strong) IBOutlet UILabel *dateLabel;
@property (nonatomic, strong) IBOutlet UILabel *typeLabel;
@end
EventCell.m
#import "EventCell.h"
@implementation EventCell
@synthesize titleLabel, locationLabel, dateLabel, typeLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
Hier ist, wie ich meine Zelle bin einrichten.
EventsMasterViewController.m
- (EventCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Event *myEvent;
NSString *CellIdentifier = @"EventCell";
EventCell *cell = (EventCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"EventCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[EventCell class]])
{
cell = (EventCell *)currentObject;
break;
}
}
myEvent = [self.myEventsDataController objectInListAtIndex:indexPath.row];
cell.titleLabel.text = myEvent.name;
cell.locationLabel.text = myEvent.location;
cell.typeLabel.text = @"Social";
cell.layer.borderColor = [UIColor blackColor].CGColor;
cell.layer.borderWidth = 1.0;
return cell;
}
Die Zelle groß formatiert wird, sieht es genau so, wie ich es brauchen. Aber wenn ich darauf klicke, wird die Zelle blau hervorgehoben und wechselt nicht zur nächsten Ansicht. Ich habe einen Breakpoint in meine preparedForSegue-Methode eingefügt und es wird nicht einmal aufgerufen.
Gibt es eine Möglichkeit, PrepareForSegue manuell aufzurufen? Wenn ja, wo soll ich das machen?
Was ist mit Ihrem 'tableView: didSelectRowAtIndexPath:'? – Desdenova
Ich habe keine Methode namens, müsste ich das implementieren? – ardavis
Von dem, was ich lese, verwenden wir 'prepareForSegue' anstelle von' didSelectRowAtIndexPath'? – ardavis