Iphone 从该类内的方法调用中删除superview

Iphone 从该类内的方法调用中删除superview,iphone,objective-c,uiview,class-design,superclass,Iphone,Objective C,Uiview,Class Design,Superclass,我现在正试图在两种观点之间切换。问题在于如何称呼它 以下是解释我的情况的最简单方法: 我有一个父视图。 使用包含表的子类ChildView。 在该表中选择一个对象后,我希望切换到该父视图的另一个子视图 母公司----- |儿童1 |儿童2 child1是Parent的一个子类,允许我访问Parent中的一个方法,该方法在子视图1和2之间切换,但由于某些原因,当从child1访问它时,它不起作用 有没有关于如何做到这一点的线索?基本代码如下: 儿童1 -作废变更视图 [super methodTo

我现在正试图在两种观点之间切换。问题在于如何称呼它

以下是解释我的情况的最简单方法:

我有一个父视图。 使用包含表的子类ChildView。 在该表中选择一个对象后,我希望切换到该父视图的另一个子视图

母公司----- |儿童1 |儿童2

child1是Parent的一个子类,允许我访问Parent中的一个方法,该方法在子视图1和2之间切换,但由于某些原因,当从child1访问它时,它不起作用

有没有关于如何做到这一点的线索?基本代码如下:

儿童1 -作废变更视图

[super methodToSwitchChildViews];
母公司 -void方法切换视图

[self.child1.view removeFromSuperView];
[self.view insertSubView:child2.view atindex:0];

Super是继承中位于子类之前的类。这里的子视图似乎是superview父视图上的视图。所以使用superview,而不是super。

好吧,我仔细研究了一下,终于找到了解决方案。如果有人遇到同样的问题,你可以这样做:

在子视图的.h文件中

@class parentViewName
然后在.m文件中添加

#import "parentViewName.h"

...

- (void) functionToRemoveSelfFromView {
   parentViewName *PARENT = [[parentViewName alloc] init];

   // You must have a method in the parent view to toggle or remove the subview, the way
   // you want it done, then call it with the new delegate. Make sure it doesn't set this 
   // view to nil or releases it because this method has yet to return. If animating do not
   // hide this view either.

   [PARENT methodToRemoveSelfFromView];
   [PARENT release];
}

你的孩子是你父母的一个子类是什么意思?这只意味着子对象具有其父对象的属性,而不是与其父对象有连接。