Header View title getting overwritten with Inherited controller

I am trying to access the properties and objects that are declared in one view controller in to the page where I need them.Did so by subclassing the view controller.But I have got a problem here,the inherited controller is making the controller overwritten.I mean the navigation bar and header view of the subclassed controller is getting displayed in the used view.When I remove the [super viewDidLoad] method,the vlaues which needs to be displayed is not getting displayed.Also the header view of the inherited view controller is getting displayed.I did subclassing using the following statement:I am also posting the code:

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 @"";
}

but not working,please help me to get out of this,thanks Mr.Ben for the answer :)

Also I have another problem,please check that too if possible,thanks in advance :)

Populate the table view sections with rows of table in sqlite database in an order

Answers


Your description is a bit confusing, but it sounds like your superclass is setting a title/button information after you set it in the subclass. Re-order your viewDidLoad so the [super viewDidLoad]; is first in the function, any subclass changes will then be applied after the superclass sets it.


Need Your Help

Trying to pass data between viewcontrollers - pass annotation title to new viewcontroller

ios uiviewcontroller

I have looked at all the other posts related to passing data between viewcontrollers but none of them are working for my problem.

How to create a UINavigationController that pushes from the top of the screen?

iphone ios uinavigationcontroller pushviewcontroller

I'm creating an iPhone app with a standard "Master-Detail" navigation, where you choose an item from a UITableView, and see the Detail view for the item in a ViewController that pushes onto the scr...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.