sandy
sandy

Reputation: 1072

UINavigation Problem

I want to navigate a class on a button click option in a View Controller class. Please give the way to do this. I am using the given following code to do this on a button click.

- (void)buttonAction {
  Status *status = [[Status alloc] init];
  [self.navigationController pushViewController:status animated:YES];
}

// Status is a UIViewController subclass

Upvotes: 0

Views: 245

Answers (1)

Ishu
Ishu

Reputation: 12787

(void)buttonAction
{
  Status *status = [[Status alloc]init];//this is not proper
  [self.navigationController pushViewController:status animated:YES]; 
}

you must use

(void)buttonAction
{
  Status *status = [[Status alloc]initWithNibName:@"YourNib" bundle:nil];
  [self.navigationController pushViewController:status animated:YES]; 
  [status release];
}

here your nib is the name of xib which you want to display.

Edit:

now you application is view based so

(void)buttonAction { so make object of appDelegate class(suppos objApp) now,

  Status *status = [[Status alloc]initWithNibName:@"YourNib" bundle:nil];
  [objApp.window addSubview:status.view]; 
  [status release];
}

Upvotes: 1

Related Questions