小编abh*_*bhi的帖子

如何拖动UITableViewCell并将其拖放到另一个UITableView?

我只能获得部分输出,实现了拖放的主要功能,但是它崩溃了一些时间并且显示错误作为索引超出范围.

我使用平移手势控制器来拖放UITableView单元格,我也想知道如何通过使用触摸开始,触摸移动和触摸结束方法来完成.

这是我的示例代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    pathNumber=indexPath.row;
    cell = [tableView cellForRowAtIndexPath:indexPath];
    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
    [cell addGestureRecognizer:panRecognizer];


    if (cell.accessoryType==UITableViewCellAccessoryNone)
    {

        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        if(tableView==tableView1)
        {
            [selectedCells addObject:[array objectAtIndex:indexPath.row]];
            NSLog(@"indexpath-%d",indexPath.row);
            [arrayOfPaths addObject:indexPath];
            NSLog(@"----%@",selectedCells);
            NSLog(@"----======%@",arrayOfPaths);
        }
        else
        {
            [selectedCells1 addObject:[array1 objectAtIndex:indexPath.row]];
            NSLog(@"indexpath-%d",indexPath.row);
            [arrayOfPaths1 addObject:indexPath];
            NSLog(@"====%@",selectedCells1);
            NSLog(@"----======]]]]]%@",arrayOfPaths1);
        }
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
        if(tableView==tableView1)
        {
            [selectedCells removeObject:[array objectAtIndex:indexPath.row]];
            [arrayOfPaths removeObject:indexPath];
            NSLog(@"----%@",selectedCells);
            NSLog(@"----======remove%@",arrayOfPaths);
        }
        else
        {
            [selectedCells1 removeObject:[array1 objectAtIndex:indexPath.row]];
            [arrayOfPaths1 removeObject:indexPath];
            NSLog(@"====%@",selectedCells1);
            NSLog(@"----======remove1%@",arrayOfPaths1);
        }
    }
}

- …
Run Code Online (Sandbox Code Playgroud)

iphone ios4 ios ios5

5
推荐指数
1
解决办法
903
查看次数

更改滑块值以更改图像强度(coreImage)时如何避免"收到内存警告"?

我正在尝试实现一种根据滑块值更改图像色调的方法,但是当我连续更改滑块值时,它会显示内存警告并且应用程序崩溃.

这是我的示例代码,我尝试使用dispatch_async

-(void)valueChanged
{
    float slideValue = slider.value;
    NSLog(@"%0.f",slideValue);

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0.5), ^{

    dispatch_async(dispatch_get_main_queue(), ^{
            [filter setValue:@(slideValue)
                      forKey:@"inputIntensity"];
            CIImage *outputImage = [filter outputImage];


            CGImageRef cgimg = [context createCGImage:outputImage
                                             fromRect:[outputImage extent]];

            UIImage *newImage = [UIImage imageWithCGImage:cgimg];
            imageView.image = newImage;


       });

    });

}
Run Code Online (Sandbox Code Playgroud)

iphone ios ios5 ios6

2
推荐指数
1
解决办法
412
查看次数

标签 统计

ios ×2

ios5 ×2

iphone ×2

ios4 ×1

ios6 ×1