Uitableviewcell separator znikający w iOS7

Mam jakiś dziwny problem z UITableView tylko w iOS 7.

UITableViewCellSeparator znika powyżej pierwszego rzędu i poniżej ostatniego rzędu. Czasami po wybraniu wierszy lub niektórych akcji przewijania pojawia się.

W moim przypadku tableView jest ładowany z Storyboard ze stylem UITableViewStylePlain. Problem z pewnością nie jest w UITableViewCellSeparatorStyle, który nie jest zmieniany z domyślnego UITableViewCellSeparatorStyleSingleLine.

Jak przeczytałem na Apple Dev Forums (tutaj i tutaj) inni ludzie mają takie problem i niektóre obejścia można znaleźć, na przykład:

Workaround: disable the default selection and recreate the behaviour in a method
trigged by a tapGestureRecognizer.

Ale nadal szukam powodu takiego dziwnego zachowania separatora.

Jakieś pomysły?

Aktualizacja: jak widziałem w XCode 5.1 DP i IOS 7.1 beta, Apple próbował rozwiązać ten problem. Teraz separator jest wyświetlany w razie potrzeby czasami pod ostatnim wierszem, po pewnym odświeżeniu, ale nie po utworzeniu tableview.

Author: Ortwin Gentz, 2013-09-20

30 answers

Rzuciłem hierarchię subview dotkniętych komórek i okazało się, że {[2] } został ustawiony na ukryty. Nic dziwnego, że nie pokazano!

Przekroczyłem layoutSubviews w mojej podklasie UITableViewCell i teraz separatory są wyświetlane niezawodnie:

Objective-C :

- (void)layoutSubviews {
    [super layoutSubviews];

    for (UIView *subview in self.contentView.superview.subviews) {
        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
            subview.hidden = NO;
        }
    }
}

Swift :

override func layoutSubviews() {
    super.layoutSubviews()

    guard let superview = contentView.superview else {
        return
    }
    for subview in superview.subviews {
        if String(subview.dynamicType).hasSuffix("SeparatorView") {
            subview.hidden = false
        }
    }
}

Inne proponowane tutaj rozwiązania nie działały dla mnie konsekwentnie lub wydawały się niezgrabne (dodawanie niestandardowych widoków Stopki 1 px).

 77
Author: Ortwin Gentz,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-31 14:44:33

To mi pomogło:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // fix for separators bug in iOS 7
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
 42
Author: samvermette,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-21 01:23:32

Miałem również problem z brakującym separatorem i dowiedziałem się, że problem wystąpił tylko wtedy, gdy heightForRowAtIndexPath było zwracanie liczby dziesiętnej . Rozwiązanie:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return ceil(yourHeight) // Ceiling this value fixes disappearing separators
}
 12
Author: Emelie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-28 12:42:59

Czy próbowałeś dodać UIView wysokości 1 w nagłówku i stopce tabeli z jasnoszarym kolorem tła? Zasadniczo wyśmiewa pierwszy i ostatni separator.

 11
Author: airpaulg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-28 21:22:56

@ samvermette

Naprawiłem problem używając tej metody delegata. Teraz nie migocze:

-(void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    // fix for separators bug in iOS 7
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}


-(void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    // fix for separators bug in iOS 7
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}
 8
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-06 12:14:57

Napotkaliśmy ten problem w naszej aplikacji. Gdy użytkownik wybrał komórkę, nowy widok tabeli został przesunięty na stos kontrolera nawigacji, a następnie gdy użytkownik go zdjął, brakowało separatora. Rozwiązaliśmy to poprzez umieszczenie [self.tableView deselectRowAtIndexPath:indexPath animated:NO]; w metodzie didSelectRowAtIndexPath table view delegate.

 7
Author: wrightak,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-17 01:13:37

Oto łatwiejsze (choć trochę niechlujne) obejście jeśli potrzebujesz, spróbuj wybrać i odznaczyć komórkę po przeładowaniu danych i wykonaniu domyślnej animacji.

Wystarczy dodać:

[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
 6
Author: redmoon7777,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-29 16:46:40

Odkryłem, że najprostszym rozwiązaniem jest, po przeładowaniu komórki, również przeładowanie komórki powyżej:

if (indexPath.row > 0) {
    NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
    [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
}
 6
Author: conmulligan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-21 23:12:37

[6]} proste i czyste rozwiązanie, które działa zarówno na iOS 8, jak i iOS 9 (beta 1)

Oto proste, czyste i nieinwazyjne obejście. Polega na wywołaniu metody category, która naprawi separatory.

Wszystko, co musisz zrobić, to przejść w dół hierarchii komórki i ukryć separator. Tak:

for (UIView *subview in cell.contentView.superview.subviews) {
    if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
        subview.hidden = NO;
    }
}

Polecam dodać to do kategorii na UITableViewCell, tak:

@interface UITableViewCell (fixSeparator)
- (void)fixSeparator;
@end

@implementation UITableViewCell (fixSeparator)

- (void)fixSeparator {
    for (UIView *subview in self.contentView.superview.subviews) {
        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
            subview.hidden = NO;
        }
    }
}

@end

Ponieważ separator może zniknąć w różnych komórka niż ta aktualnie wybrana, prawdopodobnie dobrym pomysłem jest wywołanie tej poprawki na wszystkich komórkach w widoku tabeli. W tym celu możesz dodać kategorię do UITableView, która wygląda tak:

@implementation UITableView (fixSeparators)

- (void)fixSeparators {
    for (UITableViewCell *cell in self.visibleCells) {
        [cell fixSeparator];
    }
}

@end

Mając to na swoim miejscu, możesz wywołać -fixSeparatos w widoku tableView zaraz po akcji, która powoduje ich zniknięcie. W moim przypadku było to po wywołaniu [tableView beginUpdates] i [tableView endUpdates].

Jak stwierdziłem na początku, przetestowałem to zarówno na iOS 8, jak i iOS 9. Przypuszczam, że będzie działać nawet na iOS 7, ale Nie mam jak tego spróbować. Jak zapewne wiesz, to nie majstruje z wewnętrznymi komórkami, więc może przestać działać w jakimś przyszłym wydaniu. I Apple może teoretycznie (0.001% szansa) odrzucić swoją aplikację z tego powodu, ale nie widzę, jak mogliby nawet dowiedzieć się, co robisz tam (sprawdzanie przyrostek klasy nie może być wykryty przez analizatory statyczne jako coś złego, IMO).

 4
Author: Lukas Petr,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-18 13:18:28

Bazując na komentarzu @ ortwin-gentz, To rozwiązanie działa dla mnie w iOS 9.

func fixCellsSeparator() {

    // Loop through every cell in the tableview
    for cell: UITableViewCell in self.tableView.visibleCells {

        // Loop through every subview in the cell which its class is kind of SeparatorView
        for subview: UIView in (cell.contentView.superview?.subviews)!
            where NSStringFromClass(subview.classForCoder).hasSuffix("SeparatorView") {
                subview.hidden = false
        }
    }

}

(Kod Swift)

Używam funkcji fixcellsseparator() po wywołaniu endUpdates () w niektórych metodach tableView, na przykład:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    //  Perform some stuff
    //  ...

    self.tableView.endUpdates()
    self.fixCellsSeparator()

}

Mam nadzieję, że to rozwiązanie będzie dla kogoś pomocne!

 4
Author: cdalvaro,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-26 15:55:25

Uzupełnienie odpowiedzi airpaulga.

Więc w zasadzie trzeba zaimplementować dwie metody UITableDelegate. Oto moje rozwiązanie, które działa zarówno na iOS7, jak i iOS6.

#define IS_OS_VERSION_7 (NSFoundationVersionNumber_iOS_6_1 < floor(NSFoundationVersionNumber))

#define UIColorFromRGB(hexRGBValue) [UIColor colorWithRed:((float)((hexRGBValue & 0xFF0000) >> 16))/255.0 green:((float)((hexRGBValue & 0xFF00) >> 8))/255.0 blue:((float)(hexRGBValue & 0xFF))/255.0 alpha:1.0]

// spowoduje to ukrycie pustej siatki tabeli pod komórkami, jeśli nie obejmą one całego ekranu

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = nil;

    if (IS_OS_VERSION_7 /* && <is this the last section of the data source> */)
    {
        CGFloat height = 1 / [UIScreen mainScreen].scale;
        view = [[UIView alloc] initWithFrame:CGRectMake(0., 0., 320., height)];
        view.backgroundColor = UIColorFromRGB(0xC8C7CC);
        view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    }
    else
    {
        view = [UIView new];
    }
    return view;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (IS_OS_VERSION_7 /* && <is this the last section of the data source> */)
    {
        return 1 / [UIScreen mainScreen].scale;
    }
    else
    {
        // This will hide the empty table grid below the cells if they do not cover the entire screen
        return 0.01f;
    }
}
 2
Author: ivohad,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-09 17:59:52

To naprawiło problem dla mnie:

Upewnij się, że clipsToBounds jest ustawione na tak dla komórki, ale nie dla komórki contentView. Również ustawić cell.contentView.backgroundColor = [UIColor clearColor];

 2
Author: JimmyB,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-02-14 04:55:03

Wydaje się, że ten problem przejawia się w tak wielu okolicznościach.

Dla mnie miało to coś wspólnego z selekcją komórek. Nie mam pojęcia dlaczego i nie miałem czasu, aby zagłębić się w to zbyt głęboko, ale mogę powiedzieć, że zaczęło się, gdy ustawiłem selectionStyle komórki na none. ie:
//This line brought up the issue for me
cell.selectionStyle = UITableViewCellSelectionStyleNone;

Próbowałem użyć niektórych metod delegatów powyżej, które włączają i wyłączają właściwość separatorStyle tableView, ale wydawało się, że nie robią nic, aby rozwiązać mój problem.

Cały powód, dla którego tego potrzebowałem, to bo nawet nie potrzebowałem wyboru komórki.

Więc znalazłem coś, co dla mnie zadziałało. Właśnie wyłączyłem selekcję na UITableView:
tableView.allowsSelection = NO;

Mam nadzieję, że to komuś pomoże, jeśli nie musisz mieć wyboru komórki.

 2
Author: Arjun Mehta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-26 22:11:17

Próbowałem tak wielu sugestii, aby naprawić, ale nie mogę tego naprawić.W końcu zdecydowałem się na niestandardową linię separatora jak poniżej:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    var lineView = UIView(frame: CGRectMake(20, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width - 20, 1))

    lineView.backgroundColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1)
    cell.contentView.addSubview(lineView)
}

P / S: custom at willDisplayCell NOT cellForRowAtIndexPath

 2
Author: lee,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-08-18 06:31:11

Dość zaskakujące, zmiana wartości komórki separatorInset tam i z powrotem wydaje się działać:

NSIndexPath *selectedPath = [self.controller.tableView indexPathForSelectedRow];
[self.controller.tableView deselectRowAtIndexPath:selectedPath animated:YES];

UITableViewCell *cell = [self.controller.tableView cellForRowAtIndexPath:selectedPath];
UIEdgeInsets insets = cell.separatorInset;
cell.separatorInset = UIEdgeInsetsMake(0.0, insets.left + 1.0, 0.0, 0.0);
cell.separatorInset = insets;
 1
Author: Bartosz Ciechanowski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-16 10:52:43

Miałem również problem z tym niespójnym wyświetlaczem linii separatora na dole mojego widoku UITableView. Korzystając z niestandardowego widoku stopki, udało mi się utworzyć podobną linię I wyświetlić ją na szczycie potencjalnej istniejącej (której czasami brakowało).

Jedynym problemem tego rozwiązania jest to, że jabłko może pewnego dnia zmienić grubość linii

- (UIView*) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    float w = tableView.frame.size.width;

    UIView * footerView =  [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, 1)];
    footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    footerView.clipsToBounds=NO;

    UIView* separatoraddon = [[UIView alloc] initWithFrame:CGRectMake(0, -.5, w, .5)];
    separatoraddon.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    separatoraddon.backgroundColor = tableView.separatorColor;
    [footerView addSubview:separatoraddon];

    return footerView;
}
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}
 1
Author: Paco_777,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-04-06 19:42:17

Postanowiłem umieścić te linie kodu, w których pojawia się aktualizacja tableview:

self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;

Na przykład w moim przypadku umieściłem je tutaj:

tableView.beginUpdates()
tableView.insertRowsAtIndexPaths(insertIndexPaths, withRowAnimation: UITableViewRowAnimation.Fade)
tableView.endUpdates()
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
 1
Author: Andorath,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-09 16:32:23

Musisz usunąć zaznaczenie komórki przed wykonaniem aktualizacji komórki. Następnie możesz przywrócić zaznaczenie.

NSIndexPath *selectedPath = [self.tableview indexPathForSelectedRow];
    [self.tableview deselectRowAtIndexPath:selectedPath animated:NO];
    [self.tableview reloadRowsAtIndexPaths:@[ path ] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableview selectRowAtIndexPath:selectedPath animated:NO scrollPosition:UITableViewScrollPositionNone];
 1
Author: Voloda2,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-12 11:12:02

Aby rozwiązać powyższy problem, Dodaj pustą stopkę w viewDidLoad.

UIView *emptyView_ = [[UIView alloc] initWithFrame:CGRectZero];   
emptyView_.backgroundColor = [UIColor clearColor];  
[tableView setTableFooterView:emptyView_];

Proszę nie używać powyższych linii w metodzie viewforfooterinsection delegate. Oznacza, że nie implementuje metody viewForFooterInSection.

 1
Author: Suresh Durishetti,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-04-18 12:36:37

Do rozszerzenia na airpaulg answer, bo to nie do końca działa dla mnie..

Musiałem również zaimplementować metodę heightforfooter, aby uzyskać wysokość

Potem zauważyłem, że lightgraycolor jest zbyt ciemny. naprawiłem to, pobierając bieżący kolor separatora widoku tableview i używając tego:

UIColor *separatorGray = [self.briefcaseTableView separatorColor]; [footerSeparator setBackgroundColor:separatorGray];

 0
Author: skinsfan00atg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-26 17:39:37

Napotkałem również ten problem w naszym projekcie. Mój widok tabeli miał widok tableFooterView, który mógł to zrobić. Znalazłem separator poniżej ostatniego wiersza pojawi się, jeśli usunąłem ten tableFooterView.

 0
Author: xT_Tx,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-02-22 11:37:43

Dla mnie różnica polegała na przeładowaniu wiersza, dla którego nie pojawiłaby się dolna linia separatora:

NSIndexPath *indexPath = 
     [NSIndexPath indexPathForRow:rowIndex inSection:sectionIndex];  
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
 0
Author: Don Miguel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-02 15:00:21

Rozwiązuję ten problem w inny sposób: dodaj do tableview warstwę, której wysokość wynosi 0,5 px, a jej kolor to lightgray.tableFooterView jako jego podwarstwy.

Kod jest taki:

UIView *tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 70)];
CALayer *topSeperatorLine = [CALayer layer];
topSeperatorLine.borderWidth = 0.5f;
topSeperatorLine.borderColor = [UIColor lightGrayColor].CGColor;
topSeperatorLine.frame = CGRectMake(0, 0, 320, 0.5f);
[tableFooterView.layer addSublayer:topSeperatorLine];
self.tableView.tableFooterView = tableFooterView;
 0
Author: jianpx,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-22 03:25:17

W podklasie UITableViewCell zaimplementuj layoutSubviews i dodaj:

- (void)layoutSubviews{
    [super layoutSubviews]
    for (UIView *subview in self.contentView.superview.subviews) {
        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
            CGRect separatorFrame = subview.frame;
            separatorFrame.size.width = self.frame.size.width;
            subview.frame = separatorFrame;
        }
    }
}
 0
Author: Giorgos Ath,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-09 13:03:25

Jak ktoś inny wspomniał, problem ten wydaje się przejawiać na różne sposoby. Rozwiązałem problem za pomocą następującego obejścia:

[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
 0
Author: chinabuffet,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-07 18:16:12

Przeglądając odpowiedzi i rozwiązania wpadłem na takie spostrzeżenia:

Jest to bardzo proste i łatwe w użyciu. Zauważyłem problem przy wybraniu komórki z kodu w metodzie viewDidLoad tak:

1) obejście zostało zrobione w viewDidAppear: jeśli komuś nie przeszkadza zauważalne opóźnienie między wyświetlaniem widoku a zaznaczeniem komórki

2) drugie rozwiązanie zadziałało dla mnie, ale kod wygląda trochę krucho, ponieważ opiera się na wewnętrznej implementacji UITableViewCell

3) dodanie własnego separatora wydaje się być na razie najbardziej elastyczne i najlepsze, ale wymaga więcej kodowania:)

 0
Author: Julian Król,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:32

Ustawienie stylu w viewWillAppear zadziałało na mnie.

 0
Author: villy393,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-21 09:55:32

Ponieważ jest to nadal problem z IOS 8, dodam moje rozwiązanie w języku Swift. Ustaw linię separatora tableview na brak. Następnie dodaj ten kod do metody delegata cellForRowAtIndexPath. Doda ładny separator. Instrukcja if pozwala zdecydować, które komórki powinny mieć separator.

    var separator:UIView!
    if let s = cell.viewWithTag(1000)
    {
        separator = s
    }
    else
    {
        separator = UIView()
        separator.tag = 1000
        separator.setTranslatesAutoresizingMaskIntoConstraints(false)
        cell.addSubview(separator)

        // Swiper constraints
        var leadingConstraint = NSLayoutConstraint(item: separator, attribute: .Leading, relatedBy: .Equal, toItem: cell, attribute: .Leading, multiplier: 1, constant: 15)
        var heightConstraint = NSLayoutConstraint(item: separator, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 0.5)
        var bottomConstraint = NSLayoutConstraint(item: cell, attribute: .Bottom, relatedBy: .Equal, toItem: separator, attribute: .Bottom, multiplier: 1, constant:0)
        var trailingConstraint = NSLayoutConstraint(item: cell, attribute: .Trailing, relatedBy: .Equal, toItem: separator, attribute: .Trailing, multiplier: 1, constant: 15)
        cell.addConstraints([bottomConstraint, leadingConstraint, heightConstraint, trailingConstraint])
    }

    if indexPath.row == 3
    {
        separator.backgroundColor = UIColor.clearColor()
    }
    else
    {
        separator.backgroundColor = UIColor.blackColor()
    }
 0
Author: Bjørn Ruthberg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-29 11:31:09

Oto moje rozwiązanie tego problemu. Po wstawieniu komórki(komórek) przeładuj sekcję. Jeśli przeładowanie całej sekcji jest dla Ciebie zbyt intensywne, po prostu przeładuj ścieżki indeksowe powyżej i poniżej.

[CATransaction begin];
[CATransaction setCompletionBlock:^{
    //  Fix for issue where seperators disappear

    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
}];

[self.tableView insertRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationFade];

[CATransaction commit];
 0
Author: mattsven,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-11 17:36:22

Napotkałem podobny problem, odkryłem, że Innym dobrym rozwiązaniem, szczególnie jeśli twoje źródło danych nie jest duże, jest przeładowanie tableData podczas implementacji metody -(void)scrollViewDidScroll:(UIScrollView *)scrollView, Oto przykład:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
      if (scrollView == self.tableView1) {
          [self.tableView1 reloadData];
      }

      else {
          [self.tableView2 reloadData];
      }
}

Możesz również przeładować niewidoczne dane na podstawie widocznego źródła danych, ale to wymaga więcej hakowania.

Pamiętaj, że ta funkcja delegata podlega protokołowi UITableViewDelegate!

Mam nadzieję, że to pomoże!
 0
Author: smahmood11,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-05 16:36:15