开发者

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?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜