I have a DetailViewController, which is pushed/entered from RootViewController1 OR RootViewController2 through storyboard segues when Cell is selected.
DetailViewController 有一个带有IBAction
. 我可以像这样编写动作:
如果父 ViewController 是 RootViewController2,则返回。否则,执行操作。像这样的东西:
-(IBAction)actionButtonPressed:(id)sender
{
if (parentViewController == RootViewController2) {
return;
}
//Else this is done:
textLabel.text = @"Test";
}
但我不知道如何使它工作,这样的一个例子会很棒。如果您需要更多信息,请告诉我!
编辑:
代码现在看起来像这样:
#import "RootViewController2.h"
...
-(IBAction)actionButtonPressed:(id)sender
{
if([self.parentViewController isKindOfClass:[RootViewController2 class]]) {
return;
}
//Else this is done:
textLabel.text = @"Test";
}
但是仍然从两个视图执行操作。进一步的建议?