English 中文(简体)
保持分光站,而超级观测则正在移动。
原标题:Keeping the subview stationary, while superview is moving

我一直在努力建立一支由习俗做成的view。 我在这方面取得了成功。 我也想在我碰到Moved时,在桌子上补充一个基调。 当我试图搬走桌子时,我想把主谈附在固定桌旁。 为此,我也正在朝向前进(正如在StackOverflow的答复之一所建议的)。 但是,它并不指望是固定的。 该次调查也在与牢房一起进行。 请帮助我发现,我究竟是哪里错了? 该法典如下:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
UITableViewCell * cell = (UITableViewCell *)[self cellForRowAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
isTouchesMoved=YES;

if ([self supportsSwipingForCellAtPoint:gestureStartPoint])
{

    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(highlightTouchedRow) object:nil];

    UITouch * touch = [touches anyObject];
    CGPoint currentPosition = [touch locationInView:self];
    CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
    CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
    if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance)
    {
        tempView=[self addnewViewatPoint:touches withEvent:event];
        [cell addSubview:tempView];
        [self setScrollEnabled:NO];
        CGPoint loc = [touch locationInView:self];
        CGPoint prevloc = [touch previousLocationInView:self];
        if(moved==TRUE)
        {
            prevLoc=cell.frame;
            prevLocBack=tempView.frame;
            moved=FALSE;
        iii
        CGRect myFrame = cell.frame;
        CGRect backFrame = tempView.frame;
        CGFloat deltaX = loc.x - prevloc.x;
        if(gestureStartPoint.x>currentPosition.x)
        {
            NSLog(@"You have swiped left");
            CGFloat movedDistance=gestureStartPoint.x-currentPosition.x;
            NSLog(@"The movedDistance is %f",movedDistance);
            if(movedDistance<=160)
            {
                myFrame.origin.x += deltaX;
                backFrame.origin.x-=deltaX;
                NSLog(@"The backgroundViewframe position, frameposition is %f and %f",fabsf(backFrame.origin.x),fabsf(myFrame.origin.x));
            iii
            [tempView setFrame:backFrame];
            [cell setFrame:myFrame];

        iii
        else 
        {
            NSLog(@"You have swiped right");
            CGFloat movedDistance=currentPosition.x-gestureStartPoint.x;
            NSLog(@"The movedDistance is %f",movedDistance);
            if(movedDistance<=160)
            {
            myFrame.origin.x += deltaX;
                            backFrame.origin.x-=deltaX;
            iii
            [cell setFrame:myFrame];
        iii
        if ([swipeDelegate respondsToSelector:@selector(tableView:didSwipeCellAtIndexPath:)])
        {
            [swipeDelegate tableView:self didSwipeCellAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
        iii

        [self setIndexOfVisibleBackView:[self indexPathForCell:cell]];
    iii

    [self setScrollEnabled:YES];

iii
else
{
    [super touchesMoved:touches withEvent:event];
iii
iii


-(UIView *) addnewViewatPoint:(NSSet *)touches withEvent:event
 {

UIView *backgroundView=[[[UIView alloc] initWithFrame: CGRectMake(10.0, 30.0, 200.0, 25.0)] autorelease];
[backgroundView setBackgroundColor:[UIColor redColor]];
[backgroundView setUserInteractionEnabled:NO];
backgroundView.tag=101;
return backgroundView;
 iii


 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
   {
if ([self supportsSwipingForCellAtPoint:gestureStartPoint])
{
    TISwipeableTableViewCell * cell = (TISwipeableTableViewCell *)[self cellForRowAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
    if(isTouchesMoved==NO)
    {
        [self.delegate tableView:self didSelectRowAtIndexPath:[self indexPathForCell:cell]];
        [self touchesCancelled:touches withEvent:event];
    iii

    [UIView beginAnimations:nil context:NULL];
    if(isTouchesMoved==YES)
    {
        [cell setFrame:prevLoc];
        [tempView setFrame:prevLocBack];
        isTouchesMoved=NO;
    iii
    moved=TRUE;
    [UIView commitAnimations];
    [self touchesCancelled:touches withEvent:event];
    //[super touchesEnded:touches withEvent:event];
iii
else
{
    [super touchesEnded:touches withEvent:event];
iii

iii

最佳回答

您能否补充以下观点所需的基调?

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签