To robi moją głowę :-)Niestandardowe UITableViewCell w trybie edycji nie porusza moje UILabels
mam w pełni funkcjonalny CoreData Zaludnionych UITableView
wewnątrz UIViewController
a ja z powodzeniem wdrożył „przesunąć usunąć opcję” (co jest łatwe) i mogę również usuwać pojedyncze instancje za pomocą przycisku edycji, w którym pojawia się czerwone kółko.
Moim problemem jest i myślę, że to dlatego, że mam CustomCell, że po naciśnięciu przycisku edycji UILabels
nie przesuwa się w prawo.
Próbowałem używać -(void)layoutSubViews
i kilku innych, ale nic nie działa.
Napisałem swój kod do mojego cellForRowAtIndexPath
. Jest to część sekcji notatek w mojej aplikacji. Ten kod działa, po prostu muszę wiedzieć Jak przenieść etykiety, kiedy wchodzę w tryb edycji?
Dziękuję za wskazówki i porady :-)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
MNCustomCell *cell = [_mainTableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[MNCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
//cell.textLabel.text = [_tableArray objectAtIndex:indexPath.row];
MNotes *mnotes = [[self fetchedResultsController] objectAtIndexPath:indexPath];
cell.noteTitle.text = mnotes.noteTitleString;
cell.noteSummary.text = mnotes.mainNoteString;
mnotes.createDate = [[NSDate alloc] init];
SORelativeDateTransformer *relativeDateTransformer = [[SORelativeDateTransformer alloc] init];
NSString *relativeDate = [relativeDateTransformer transformedValue:mnotes.createDate];
cell.noteDate.text = relativeDate;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
-
//This is the Custom Cell
@interface MNCustomCell : UITableViewCell
{
}
@property (strong, nonatomic) IBOutlet UILabel *noteTitle;
@property (strong, nonatomic) IBOutlet UILabel *noteDate;
@property (strong, nonatomic) IBOutlet UITextView *noteSummary;
@end
-
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.contentView addSubview:_noteTitle];
[self.contentView addSubview:_noteSummary];
[self.contentView addSubview:_noteDate];
}
return self;
}
Czy etykiety dodawane bezpośrednio do komórki czy też dodać je do komórki 'contentView'? Powinny one znajdować się w 'contentView', aby automatycznie dostosowywały się, gdy komórka przechodzi do trybu edycji lub dodawane są inne dekoracje komórek. – rmaddy
Stworzyłem nową klasę niestandardową i przeciągnąłem je do tego z Storyboard - myślę, że to oznacza, że są bezpośrednio na komórce, prawda? –
Dodałem kod dla mojej komórki niestandardowej - Nie dodałem nic w pliku .m - nie musiałem się do tej pory. –