Hallo allerseits Ich bin ein Neuling für iOS.Move UITableViewCell
Ich habe eine UITableView
mit 3 Abschnitten in UITableViewController
implementiert. Und ich habe die Abschnittszeilen für jeden Abschnitt angezeigt.
- (void)viewDidLoad
{
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.navigationItem.rightBarButtonItem = self.editButtonItem;
sectionTittle=[[NSMutableArray alloc]initWithObjects:@"Real Madrid",@"Barcelona",@"Liverpool", nil];
firstSection=[[NSMutableArray alloc]initWithObjects:@"Cr7",@"Garath Bale",@"Pepe",
nil];
secondSection=[[NSMutableArray alloc]initWithObjects:@"Lionel Messi",@"Neymar",@"Pique",
nil];
thirdSection=[[NSMutableArray alloc]initWithObjects:@"Gerrard",@"Saurez",@"Lallana",
nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return sectionTittle.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section==0)
{
return [firstSection count];
}
if(section==1)
{
return [secondSection count];
}
if(section==2)
{
return [thirdSection count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"hi" forIndexPath:indexPath];
cell.textLabel.textColor=[UIColor brownColor];
if (indexPath.section == 0)
{
cell.textLabel.text=[firstSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 1)
{
cell.textLabel.text = [secondSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 2)
{
cell.textLabel.text = [thirdSection objectAtIndex:indexPath.row];
}
// Configure the cell...
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [sectionTittle objectAtIndex:section];
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
Jetzt sieht meine Ausgabe wie folgt:
ich die Zeilen zwischen den diesen drei Abschnitten verschieben möchten. Wie kann ich es tun..? Während ich es versuche, bewegt sich die Reihe zwischen dem Abschnitt, aber beim Speichern erzeugt es ein Problem.
Wie kann ich durchgehen ..?
Dank
Was macht dieser Code? Wie funktioniert es? Und woher hast du es kopiert? –