【发布时间】:2011-01-20 14:00:50
【问题描述】:
我目前正在从事一个具有很多相似性和很多观点的项目。
我会知道是否有办法将子视图从根类发送到继承类。
这是我的 RootViewController :
@class CustomView;
@interface RootViewController : UIViewController {
IBOutlet CustomView *_aCustomView;
}
@end
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
UISwipeGestureRecognizer *swipRecognizer;
// swipe left management
swipRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSwipeFrom:)];
swipRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
swipRecognizer.numberOfTouchesRequired = 2;
swipRecognizer.delegate = self;
[self.view addGestureRecognizer:swipRecognizer];
[swipRecognizer release];
}
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
NSLog(@"swip detected");
[self.view addSubview:_aCustomView];
}
HomeViewController:
@interface HomeViewController : RootViewController {
}
@end
我会创建一些从我的RootViewController 继承的 ViewController,例如 HomeViewController,以便保存行代码。当我在我的HomeViewController 中时,我可以很好地检测到我的滑动,但我还没有设法将我的自定义subView(来自我的 RootViewController)添加到我的 HomeViewController。
非常感谢。
问候,
kl94
【问题讨论】:
-
与什么相似?你的问题不清楚。您能否让我们知道您尝试了什么以及它是如何不起作用的?您是什么意思将子视图从根类“发送”到继承类?
-
我同意,我的问题不清楚。抱歉...我已经编辑了我的帖子,希望你能理解我的需要。
标签: iphone objective-c ipad inheritance view