【问题标题】:Swap positions UIImageViews second time Xcode交换位置 UIImageViews 第二次 Xcode
【发布时间】:2013-07-07 12:58:44
【问题描述】:

我有问题。当我使用下面的代码时,我可以第一次交换相同的 UIImageViews。第二次,它们回到原来的位置或相互重叠。

示例代码:

if (CGRectIntersectsRect(view1.frame, view2.frame)) {
   [UIView animateWithDuration:0.2 animations:^{
     CGRect view1Frame = view1.frame;
     view1.frame = view2.frame;
     view2.frame = view1Frame;
   }];
}

如何每次都交换 UIImageViews 的位置? 非常感谢您的帮助!

【问题讨论】:

标签: objective-c xcode uiimageview swap


【解决方案1】:

你把它变成了一个方法吗?

-(void) swapLocWith: (UIView *) view1 and: (UIView *) view2
{
   //your code sample here
}
...
-(void) someMethod
{
    //swap once
    [self swapLocWith: view1 and: view2]; 
    //swap back
    [self swapLocWith: view2 and: view1];
}

【讨论】:

    猜你喜欢
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-03
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    相关资源
    最近更新 更多