Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将按钮从UIView拖放到另一个UIVview_Ios_Objective C_Drag And Drop - Fatal编程技术网

Ios 将按钮从UIView拖放到另一个UIVview

Ios 将按钮从UIView拖放到另一个UIVview,ios,objective-c,drag-and-drop,Ios,Objective C,Drag And Drop,我使用了90个按钮&视图,按钮必须从一个视图移动到另一个视图,标签值必须相同,只有视图必须更改。嗨,最后我得到了问题的答案 - (IBAction)reloadScrollView //reposition subviews or swap the subview { HButton *view = nil; NSArray *subviews = [self.superview subviews]; NSInteger i = 0; NSInteger FLAG=0; [UIView

我使用了90个按钮&视图,按钮必须从一个视图移动到另一个视图,标签值必须相同,只有视图必须更改。

嗨,最后我得到了问题的答案

- (IBAction)reloadScrollView    //reposition subviews or swap the subview
{ 
HButton *view = nil;

NSArray *subviews = [self.superview subviews];
NSInteger i = 0;
NSInteger FLAG=0;
[UIView beginAnimations:@"relayoutView" context:nil];
// To find and swap the subviews
for (view in subviews)
{
    if ([view isKindOfClass:[HButton class]])
    {
        HButton *check=[subviews objectAtIndex:i];

        if([self.titleLabel.text isEqualToString:@"1"])
        {
             if(![self.titleLabel.text isEqualToString:check.titleLabel.text])//check for same attribut if it is not it will enter
             {
                 NSInteger Compare=check.tag-self.tag;

                 switch (Compare) {
                         // Horizontal

                     case -2:
                     {
                         // get the middle position from the check tag
                         NSInteger _new = check.tag +1;

                         // Linq Query - Kind of SQL Query

                         // from view in SubView
                         // where view.tag == _new
                         // select viwe


                         HButton *newCheck=[subviews objectAtIndex:_new];

                         if ([newCheck.titleLabel.text isEqualToString:@"1"])
                         {
                             // now check the value
                             rect1 = self.frame;
                             rect2 = check.frame;
                             if(CGRectIntersectsRect(self.frame,check.frame)) //check two subview intersecting or not
                             {
                                 //your code for intersection here
                                 FLAG++;
                                 //   NSLog(@"%d",FLAG );
                                 int temptag;
                                 temptag=self.tag;
                                 self.tag=check.tag;
                                 check.tag=temptag;
                                 tempfrom=check;
                                 tempto=self;
                                 check.center=CGPointMake(homePosition.x , homePosition.y);
                                 self.frame=rect2;
                                 return;
                             }
                         }
                     }

那里有很多很难读懂的代码,并且没有描述它的错误…几乎可以正常工作,但标记值没有正确替换,如果您有任何示例源代码,请将其发送给我…@Wainis关心按钮的标记值到下一个视图控制器的问题?您如何使用按钮填充视图?它是IB文件还是从数组/dict中获取它们?我使用数组检查子视图中的特定标记。[UIView beginAnimations:@“relayoutView”上下文:nil];这条线的目的