ho la mia matrice:scorri per eliminare TableView Row
self.colorNames = [[NSArray alloc]
initWithObjects:@"Red", @"Green",
@"Blue", @"Indigo", @"Violet", nil];
Ho provato tutto quello che riesco a trovare, ma c'è sempre errori. Voglio essere in grado di scorrere in modo che venga visualizzato il pulsante Elimina, quindi premere il pulsante Elimina e rimuovere quella riga.
codice completa (tutto ciò che riguarda la tabella):
// HEADER FILE
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *tableView;
NSMutableArray *colorNames;
}
@property (strong, nonatomic) NSArray *colorNames;
@end
// IMPLEMENTATION
#import "ViewController.h"
@implementation ViewController
@synthesize colorNames;
- (void)viewDidLoad {
[super viewDidLoad];
self.colorNames = [[NSMutableArray alloc]
initWithObjects:@"Red", @"Green",
@"Blue", @"Indigo", @"Violet", nil];
[super viewDidLoad];
//[tableView setEditing:YES animated:NO];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int count = [colorNames count];
return count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell.
cell.textLabel.text = [self.colorNames objectAtIndex: [indexPath row]];
return cell;
}
che hai postato solo un 'NSArray' qui. Si prega di pubblicare il codice relativo per come si imposta 'UITableView'. – PengOne
È lì. Si prega di offrire qualsiasi input possibile, in quanto apprezzo qualsiasi tipo di aiuto. – JTApps