UIButton in a view based application
This is a view-based application
开发者_开发知识库i have a button in the ViewController.m Added a new subview controller class and trying to open the new view when the button is clicked.
Code :
- (IBAction) accessByProducts: (id) sender {
if(self.accessByProducts == nil) {
AccessByProducts *acb = [[AccessByProducts alloc] initWithNibName:@"AccessByProducts" bundle:[NSBundle mainBundle]];
self.accessByProducts = acb;
[acb release];
}
}
but it doesn't seem to open up . can anyone help me or guide me on this.
Thanks.
Try this:
if(self.accessByProducts == nil) {
AccessByProducts *acb = [[AccessByProducts alloc] initWithNibName:@"AccessByProducts" bundle:[NSBundle mainBundle]];
self.accessByProducts = acb;
[self.view addSubview:acb.view]; //add as sub view
[acb release];
}
Also, what type is your self.accessByProducts and does it do anything more than just keeping a reference?
精彩评论