Pregunta

Estoy tratando de acceder a las propiedades y objetos que se declaran en un controlador de visión en la página donde las necesito. Subcentando el controlador de vista. Pero tengo un problema aquí, el controlador heredado está haciendo que el controlador esté sobrescribido. Me refiero a que la barra de navegación y la vista de encabezado del controlador subclasificado se muestran en la vista usada. Cuando elimino el método [Super ViewDidload], las vlaues que deben mostrarse no se muestra. También la vista de encabezado de la vista hereditaria Se está mostrando el controlador. Subclase utilizando la siguiente declaración: también estoy publicando el código:

ERViewEditController class:

    @interface ERViewEditController:ERAddReminderController
    {

        UITableView *theTable;

    }

    @property(nonatomic,retain) IBOutlet UITableView *theTable;

    @end

    @implementation ERViewEditController

    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
     - (void)viewDidLoad
     {
         self.view.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];
         self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(pop:)];
         self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(edit:)];

         [self setTitle:@"Reminders Listed"];

         [self.theTable reloadData];
         [super viewDidLoad];
     }

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

        NSString *CellId = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row];

        UITableViewCell *cell = (UITableViewCell *)[view dequeueReusableCellWithIdentifier:CellId];

        UILabel *label1 = [[[UILabel alloc]initWithFrame:CGRectMake(54, 3, 100, 40)]autorelease];
        label1.backgroundColor = [UIColor clearColor];
        label1.textColor = [UIColor whiteColor];

        UILabel *label2 = [[[UILabel alloc]initWithFrame:CGRectMake(119, 3, 100, 40)]autorelease];
        label2.backgroundColor = [UIColor clearColor];
        label2.textColor = [UIColor whiteColor];

        UILabel *label3 = [[[UILabel alloc]initWithFrame:CGRectMake(198, 3, 100, 40)]autorelease];
        label3.backgroundColor = [UIColor clearColor];
        label3.textColor = [UIColor whiteColor];

        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellId] autorelease];
            view.backgroundColor = [UIColor clearColor];
            cell.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"reminderbutton.png"]];

            if (indexPath.section == 0) 
            {
                UILabel *label = [[[UILabel alloc]initWithFrame:CGRectMake(20, 3, 280, 40)]autorelease];
                label.backgroundColor = [UIColor clearColor];
                label.text = @" ID   Name     Event          Date";
                label.textColor = [UIColor cyanColor];
                [cell addSubview:label];
            }   

            else if (indexPath.section == 1)
            {
                const char *dbpath = [databasePath UTF8String];
                sqlite3_stmt *statement;

                if (sqlite3_open(dbpath, &remindersDB) == SQLITE_OK)
                {
                    NSString *querySQL = [NSString stringWithFormat:@"SELECT name,event,date FROM reminders"];

                    const char *query_stmt = [querySQL UTF8String];

                    if (sqlite3_prepare_v2(remindersDB ,query_stmt , -1, &statement, NULL) == SQLITE_OK)
                    {
                        if (sqlite3_step(statement) == SQLITE_ROW)
                        {
                            NSString *nameField = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];

                            NSString *eventField = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];                    

                            NSString *dateField = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)];

                            [nameField stringByAppendingString:eventField];

                            label1.text = nameField;
                            label2.text = eventField;
                            label3.text = dateField;
                        } 

                        sqlite3_finalize(statement);
                    }
                    sqlite3_close(remindersDB);
                }

                switch (indexPath.row) 
                {
                    case 0:
                        [cell addSubview:label1];
                        [cell addSubview:label2];
                        [cell addSubview:label3];
                        break;

                    default:
                        break;
                }

            }

        }

        return cell;

    }


My navigation bar issue is resolved,now I have still been facing the header view title issue,I used the following code to fix:

-(NSString *)tableView:(UITableView *)atableView titleForHeaderInSection:(NSInteger)section
{
    return @"";
}

Pero no funciona, por favor ayúdame a salir de esto, gracias Sr. Ben por la respuesta :)

También tengo otro problema, por favor verifique eso también si es posible, gracias de antemano :)

Uplica las secciones de la vista de la tabla con filas de tabla en la base de datos SQLite en un pedido

¿Fue útil?

Solución

Su descripción es un poco confusa, pero parece que su superclase está configurando una información de título/botón después de configurarla en la subclase. Vuelva a ordenar su ViewDidload para que [Super ViewDidload]; es primero en la función, cualquier cambio de subclase se aplicará después de que la superclase la establece.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top