【问题标题】:UITouches not detectingUITouches 未检测到
【发布时间】:2010-06-08 02:47:27
【问题描述】:

在我的幻灯片 nib 文件中未检测到我的 UItouches。问题是什么?有人可以帮忙吗?


@class Slideshow;
@interface RootViewController : UIViewController{
PreferencesController *preferencesController;
Slideshow *slideshow;}

幻灯片实现

@implementation Slideshow
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
NSLog(@"touches begin");
}
- (void)viewDidLoad
{

UIImageView *frontView = [[UIImageView alloc] initWithFrame:self.view.bounds];
frontView.backgroundColor = [UIColor blackColor];
frontView.image = [UIImage imageNamed:@"apple.png"];
frontView.userInteractionEnabled = YES;

[self.view addSubview:frontView];

[frontView release];
}@end

【问题讨论】:

  • 幻灯片是什么类型的课程?它是否继承自 UIResponder?

标签: iphone cocoa xcode


【解决方案1】:

幻灯片是UIViewController,而touchesBegan 仅在UIView 上调用。你需要继承 UIView 来捕捉触摸。

【讨论】:

  • 对不起,我对 xcode 很陌生。那么我应该在当前代码中添加什么代码来继承 UIView?
猜你喜欢
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 2018-12-11
  • 2019-11-25
  • 2016-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多