2

我有一个小问题。我想接收屏幕上的所有触摸,并为每个触摸生成一个新视频。问题是,一旦放置视频,它就会拦截接触点。我尝试了各种值进入 locationInView 但到目前为止没有任何运气。我找对地方了吗?

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];

    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    [self.canvas addMovie:player];

 }
 @end
4

2 回答 2

3

是的,您找对地方了,Chris 对用户交互的看法是正确的。你应该试试:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];
    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    player.userInteractionEnabled = NO;
    [self.canvas addMovie:player];
}

但是,您将遇到添加视频的问题。不幸的是,iOS / 硬件只允许您同时运行 4 个视频管道,因此您会很快达到目标

如果您想在触摸和拖动手指时向屏幕添加内容,那么您也可以在以下方法中执行上述代码:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    //work your magic here
}
于 2013-01-31T05:47:37.200 回答
3

尝试将每个视频屏幕的 userInteractionEnabled 属性(假设它保存在某种 UIView 中)设置为 NO - 这样,触摸事件将通过它并继续被您的处理程序接收。

于 2013-01-31T04:59:21.953 回答