Dodawanie małej strzałki po prawej stronie komórki w komórce TableView iPhone ' a

To powinno być dość proste.

Mam aplikację na iPhone ' a z TableView. Jak dodać małą klasyczną strzałkę po prawej stronie każdej komórki?

Author: EmptyStack, 2011-06-12

8 answers

Wystarczy ustawić odpowiednie accessoryType własność UITableViewCell .

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

In Swift 3,

cell.accessoryType = .disclosureIndicator
 264
Author: EmptyStack,
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-04-17 14:20:54

Możesz to zrobić w Interface Builder. Po prostu kliknij kliknij na widok tabeli , Przejdź do Prototype Cells po prawej stronie i ustaw go na 1. Następnie kliknij prototyp Komórki i po prawej stronie poszukaj akcesorium . Z listy rozwijanej kliknij wskaźnik ujawnienia .

Przykład konstruktora interfejsów

 54
Author: rzv,
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-08-20 16:03:54

Możesz ustawić małą klasyczną strzałkę w dwie strony, jak poniżej

1) Używanie wbudowanej metody typu akcesoriów UITableViewCell

[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; 

2) Tworzenie własnego widoku akcesoriów z własnym obrazem

(i) przeciągnij i upuść obraz strzałki (np. circle_arrow_right.png) w Twoim projekcie

(II) w metodzie projektowania komórek dla każdego wiersza jak poniżej

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

Wpisz poniższy kod:

if (cell ==nil) {
    cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:CellIdentifier]autorelease];

    //For creating custom accessory view with own image
    UIImageView *accessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [accessoryView setImage:[UIImage imageNamed:@"circle_arrow_right.png"]];
    [cell setAccessoryView:accessoryView];
    [accessoryView release];

    //Your other components on cells
     .............
    .............

 }

[Uwaga: wybierz odpowiednie obrazy do widoku akcesoriów i dodaj pożądane komórki. Wybierz małe obrazy dla widoków akcesoriów, aby uzyskać lepszą wydajność.]

 5
Author: Lalit Kumar,
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-03-04 10:38:19

Użyj właściwości accessoryType komórki, aby wyświetlić strzałkę po prawej stronie. Zobacz to .

 3
Author: Mridul Kashatria,
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
2011-06-12 15:58:18

Dla prostej strzałki:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

I dla szczegółowej strzałki:

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
 3
Author: Ravi_Parmar,
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
2012-10-23 08:32:22

Innym sposobem jest określenie UITableViewCellAccessoryDisclosureIndicator Podczas tworzenia komórki. Aby to zrobić, prawdopodobnie alloc uruchomi swoją komórkę w metodzie delegata tableViewCellWithReuseIdentifier (następnie przejdź do dostosowania i konfiguracji komórki).

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellAccessoryDisclosureIndicator reuseIdentifier:identifier];
 2
Author: Kyle Clegg,
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
2012-11-06 01:59:45

Swift 3:

cell.accessoryType = .disclosureIndicator
 2
Author: David Seek,
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-11-07 02:21:54

Najlepiej wybrać Disclosure Indicator w sekcji Accessory.

 0
Author: Uditha Prasad,
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-02-14 09:36:11