开发者

UIButton in a view based application

开发者 https://www.devze.com 2023-04-05 10:26 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号