views:

40

answers:

2

I seem to be having a problem with the titles in my application. Let me describe what is happening here.

1) starts out good with the correct image

http://img262.imageshack.us/img262/5808/picture15b.png

2) still good after clicking a cell

http://img31.imageshack.us/img31/4440/picture13dvg.png

3) after hitting the backbutton previous title remains and the last one is gone http://img150.imageshack.us/img150/5689/picture14ltq.png

4) however after scrolling up and down fast enough the correct view appears again http://img262.imageshack.us/img262/5808/picture15b.png

As you can see in the images above I'm using a UITableview however I'm NOT using the navigationItem title , I'm using a UILabel ( called title ). When I click on my cells and scroll through my application everything is fine however when I click my backbutton, which is also not a standard backbutton from the tableview, but a UIBarbuttonItem it just pops the last view (and does some other stuff too)( the button below as seen in my imagelinks).

-(void)back_clicked:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
 ....

}

It appears that my Titles do not refresh when I press the back button(which makes sense I guess since i do not have some sort of a refresh function ). I concluded this because when I scroll down really fast my original title comes back.

I noticed but could be wrong , bear with me here , that reloadData applies mostly to table ,cell constructing and such so I assume this is not the one I'm looking for. So is there some sort of refresh function I can use ?

I would really like some suggestions ;) thnx all for reading

A: 

If when you h it the back button you are coming back to another viewController i would suggest looking at the method viewWillAppear from UIViewController, you can override this method and call it before you go back, in the method implementation you can set the correct title ...reference http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController%5FClass/Reference/Reference.html#//apple%5Fref/occ/instm/UIViewController/viewWillAppear:

Daniel
thnx I'm going to look into it today
A: 

How are you inserting the UILabel that you use as a title?

Like this: [self.navigationController.navigationBar.titleView = < label >];

or more like this: [< top window > addSubview: < label >];

I've never had any problems with custom title views using the first method.

Amagrammer
title = [[UILabel alloc[ initWithFrame:Label1Frame];and then [self.navigationController.view addSubview:title];
Use this, and I think your problems will be resolved. You may have to tweak the frame a little from what you have now. [self.navigationController.navigationBar.titleView = < label >];
Amagrammer