Ich versuche zu verstehen, wie man eine Beschriftung mit einem UISwitch oder einem anderen Controller zu einer Fußzeile (oder Kopfzeile) in einer sektionierten TableView hinzufügt. Jede Hilfe würde sehr geschätzt werden. Vielen Dank im Voraus!Wie füge ich ein UIButton oder UISwitch in tableView hinzu: viewForFooterInSection
6
A
Antwort
8
Okay, nach der Suche und arbeiten an ihm habe ich die folgende getan:
// Need to refactor so that the label is Public Sharing and Priviate Sharing and the actions work for each switch
- (UIView *) tableView: (UITableView *) tableView
viewForFooterInSection: (NSInteger) section
{
if (section == 0 || section == 1) {
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
UIView* footerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)] autorelease];
footerView.autoresizesSubviews = YES;
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
footerView.userInteractionEnabled = YES;
footerView.hidden = NO;
footerView.multipleTouchEnabled = NO;
footerView.opaque = NO;
footerView.contentMode = UIViewContentModeScaleToFill;
// Add the label
UILabel* footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(150.0, -5.0, 120.0, 45.0)];
footerLabel.backgroundColor = [UIColor clearColor];
footerLabel.opaque = NO;
footerLabel.text = @"Sharing";
footerLabel.textColor = [UIColor tableHeaderAndFooterColor];
footerLabel.highlightedTextColor = [UIColor tableHeaderAndFooterColor];
footerLabel.font = [UIFont boldSystemFontOfSize:17];
footerLabel.shadowColor = [UIColor whiteColor];
footerLabel.shadowOffset = CGSizeMake(0.0, 1.0);
[footerView addSubview: footerLabel];
[footerLabel release];
// Add the switch
UISwitch* footerSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(215.0, 5, 80.0, 45.0)];
[footerView addSubview: footerSwitch];
// Return the footerView
return footerView;
}
else return nil;
}
// Need to call to pad the footer height otherwise the footer collapses
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
switch (section) {
case 0:
case 1:
return 40.0;
default:
return 0.0;
}
}
Ich hoffe, dass dies richtig ist, und wenn dies jemand hilft sonst diese bitte stimmen oben. Prost!
0
Ich glaube, Sie uiview- die
0
ich ähnlich einige Code, dass verwendet, um Autorelease brauchen ... aber ich hinzugefügt, um eine NSLog() Aufruf direkt nach dem addSubview.
Als ich blättern meine Tableview ... Ich 100s Meldung wie:
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
> Adding another subview
Ist das normal? Ich wollte nur ONE Knopf, in ONE Ansicht, ganz unten in meinem TableView.
Verwandte Themen
- 1. Wie füge ich ein Skriptpaket bedingt hinzu?
- 2. Wie füge ich ein bedingtes Pflichtfeld hinzu?
- 3. Wie füge ich ein Bild rechts von Zeilen in TableView auf dem iPhone hinzu?
- 4. JavaScript: Wie füge ich ein Attribut hinzu?
- 5. Wie füge ich "Projektbeschreibung" in FogBugz hinzu?
- 6. Wie füge ich datetimepicker hinzu und füge zweiten hinzu?
- 7. Wie füge ich Multithreading hinzu?
- 8. Wie füge ich ein TLabel zur Menüleiste in Delphi hinzu?
- 9. Wie bindet man UISwitch an UIButton enable in RxSwift?
- 10. Wie füge ich ein Dezimalfeld in einer Codeigniter-Migrationsdatei hinzu?
- 11. Wie füge ich ein Leerzeichen in einem XML-Schemaelement hinzu?
- 12. Wie füge ich ein Bild in Tkinter hinzu?
- 13. Wie füge ich ein Fragment in meiner Aktivität dynamisch hinzu?
- 14. Wie füge ich ein font-awesome Icon in @ Html.TextBoxFor hinzu?
- 15. Wie füge ich ein Drop-Down in HTML hinzu?
- 16. Wie füge ich ein Bild in Select2 Optionen hinzu?
- 17. IN DEN WARENKORB - Wie füge ich ein Schlüsselwertpaar hinzu? Php
- 18. Swift füge Badge zur Navigation hinzu barButtonItem und UIButton
- 19. Wie füge ich Ordner in dat.gui hinzu?
- 20. Wie füge ich Bilder in JTextPane hinzu?
- 21. Wie füge ich ein Element am Ende eines Arrays hinzu?
- 22. Wie füge ich ein Android-Testgerät zu Firebase hinzu?
- 23. Wie füge ich einem Img-Tag ein Ablaufdatum hinzu?
- 24. Wie füge ich einem vorhandenen Juwel ein zusätzliches Signaturzertifikat hinzu?
- 25. Wie füge ich ein Hintergrundbild zur Aktivität hinzu?
- 26. Wie füge ich eine Skala oder Achse einem Streudiagramm hinzu?
- 27. Wie füge ich ein benutzerdefiniertes expect-chain Element hinzu?
- 28. Wie füge ich ein Favicon zu einem Pelican Blog hinzu?
- 29. Wie füge ich ein Standbild zu einer AVComposition hinzu?
- 30. Wie füge ich ein Projekt zu CruiseControl.NET hinzu?