开发者

How to access a method from another classes?

In CalViewController class I have showCal method

-(IBAction) showCal{

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
if ([viewMainView superview]) {
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [viewMainView removeFromSuperview];   
    [self.view addSubview:viewCalView];
}
}

I want to call it from CustomCell class, which is a separate class with xib for custom cell. I tried like this, (buttonPressed method associate with a button in the custom cell).

-(IBAction) buttonPressed{
CalViewController *objCalViewController=[[calViewController all开发者_JAVA技巧oc] init];
[objCalViewController showCal];

}

But it doesn't work.


[objCalViewController showCal]; put a break point before it and change the function to -(void)showCal and don't forget to put the -(void)showCal in .h file of CalViewController class hope it will works for you :)


You can call a user methods [objCalViewController showCal]; in this way But there is no way you can call a IBAction method of another class simply make the function as -(void) showCal

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜