views:

239

answers:

1

Hi,

In my application(View based), the back buttons are not visible in navigation bar. If i clicked that button, the actions are working properly. Its very weird to me. Back button is visible and properly working in iPhone OS 3.0 and others.(Except OS 4.0). Now i am currently working in iPhone OS 4.0.

Here my code is,

UIButton *btn=[[UIButton alloc] init];

[btn setImage:[UIImage imageNamed:@"Back.png"] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 70, 0, 20)];
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];    
self.navigationItem.leftBarButtonItem=b;
[b release];
[btn release]; 

Please help me out.

Note:

It doesnt works only iPhone OS 4.0. So how can i achieve to this?

Thanks.

+1  A: 

Hi

Simply you replace this code wherever you want and its working fine in OS 4.0.

UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

[myView addSubview:btn];

UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,5,50,30)];

[myImage setImage:[UIImage imageNamed:@"Back.png"]];

[myView addSubview:myImage];

[btn addTarget:self action:@selector(lOut) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *b1 = [[UIBarButtonItem alloc] initWithCustomView:myView];

self.navigationItem.leftBarButtonItem = b1;

[btn release];

[b1 release];

[myView release];

[myImage release];

I hope it will help ypu.

Sivanathan