如何将UIButton标题拖放到另一个按钮标题但原始按钮保持在同一位置目标c?

时间:2015-10-06 06:26:23

标签: objective-c cocoa-touch drag-and-drop uibutton ios8.4

我已经在滚动视图中以编程方式创建了Uibutton网格。现在我需要将UI按钮标题拖放到另一个按钮。但原始按钮标题应该保持不变。我搜索stackoverflow我找到了将原始按钮或标签拖动到新的选项position.Please任何人帮我解决这个问题。 感谢

int x=0;
int y = 20;
for (int i=0; i<20; i++) //20 = total button
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:@"TEXT" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(dragOut:withEvent:)forControlEvents:UIControlEventTouchDragOutside |UIControlEventTouchDragInside];

    btn.frame = CGRectMake(10+x,y, 100, 100);
    x=x+70;
    [self.scrollView addSubview:btn];
    if((i+1)%4==0)//4 means how many buttons you need for a row
    {
        y+=110;
        x=0;
    }
}


[self.scrollView setContentSize:CGSizeMake(300, y)];

0 个答案:

没有答案