In my application which have a lot of viewcontroller classes as well as tableviewcontroller classes in all classes i want to show navigationcontroller which have
//creation of toolbar
UIToolbar *tool = [UIToolbar new];
tool.frame = CGRectMake(0, 0, 320, 42);
//create setting button
UIButton *bttn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 20, 30)];
[bttn addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchDown];
UIBarButtonItem *back=[[UIBarButtonItem alloc]initWithCustomView:bttn];
//Space
UIBarButtonItem *spbtn = [[UIBarButtonItem alloc] init];
spbtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//Show Logo
UIButton *bttn1;
bttn1= [UIButton buttonWithType:UIButtonTypeCustom];
bttn1.frame = CGRectMake(20, 0, 230, 30);
bttn1.backgroundColor = [UIColor clearColor];
[bttn1 addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
UIImage *imgss =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"pic" ofType:@"png"]];
UIImage *strechableImage1 = [imgss stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[bttn1 setBackgroundImage:strechableImage1 forState:UIControlStateNormal];
UIBarButtonItem *logo;
logo=[[UIBarButtonItem alloc]initWithCustomView:bttn1];
//assign toolbar into navigation bar
NSArray *items = [NSArray arrayWithObjects:back,logo,spbtn,nil];
[tool setItems:items animated:YES];
tool.barStyle =UIBarStyleBlackOpaque;
tool.backgroundColor = [UIColor clearColor];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tool];
I want to show navigatedtoolbar at top of every class. for this i have to write this code in every class but i want to remove repetition i define a class which have static methods i try to perform that action in this method but its generate error what can i do provide some guidance in brief .