How can I connect my button to another view controller class programmatically
here is code for my programmatically button
UIBarButtonItem *yearButton= [[UIBarButtonItem alloc] initWithTitle:@"Year" style:UIBarButtonItemStyleBordered
target:self action:@selector(year:)];
-(void) year:(id)sender{
NSLog(@"Year button clicked");
//I don't know what should I write here to connect my button to UIViewController**
//when I added this line my process is terminated**
[self performSegueWithIdentifier:@"YearView" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString: @"YearView"]){
[segue.destinationViewController setTitle:@"YearView"];
}
}
Here you can see my view in storyboard: ![enter image description here][1]
Edit: *My process is Terminated when I used this method*
-(void)year:(id)sender{
// [self performSegueWithIdentifier:@"YearView" sender:self];
NSLog(@"Year button clicked");
YearView *yearVC = [[YearView alloc] initWithNibName:@"YearView" bundle:nil];
[[self navigationController] pushViewController:yearVC animated:YES]; // [yearVC release];
}