Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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 滚动视图问题?_Ios_Iphone_Ios7 - Fatal编程技术网

Ios 滚动视图问题?

Ios 滚动视图问题?,ios,iphone,ios7,Ios,Iphone,Ios7,当我将数据直接传送到集合视图项时,我面临的滚动问题意味着它在滚动时被挂起。有什么解决方案吗 我的代码在下面 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { // Configure the cell static NSString *identifier = @"Cell";

当我将数据直接传送到集合视图项时,我面临的滚动问题意味着它在滚动时被挂起。有什么解决方案吗

我的代码在下面

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    // Configure the cell
    static NSString *identifier = @"Cell";
     NSMutableArray *image_arr;


        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    UILabel *title_lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 190, 145, 20)];


    if (boolsearch==YES)
    {

        self.scrollView.scrollsToTop=YES;

        title_lbl.backgroundColor=[UIColor colorWithRed:0.752 green:0.752 blue:0.752 alpha:0.75];
        title_lbl.text=[[arr_search_Lbl objectAtIndex:0] objectAtIndex:indexPath.row];
     cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[arr_search valueForKey:@"movie_image"] objectAtIndex:indexPath.row]]]]];
//        [cell addSubview:cellImage];


               dispatch_queue_t myqueue = dispatch_queue_create("myqueue", NULL);

                // execute a task on that queue asynchronously
                dispatch_async(myqueue, ^{
                    NSURL *url = [NSURL URLWithString:[[NSString stringWithFormat:@"%@",[[arr_search valueForKey:@"movie_image"] objectAtIndex:indexPath.row]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];;
                    NSData *data = [NSData dataWithContentsOfURL:url];

                    dispatch_async(dispatch_get_main_queue(), ^{
                        UIImage*img = [UIImage imageWithData:data];
                        NSArray *imgesArrayBeforeSearching=[NSArray arrayWithObjects:img, nil];

                        NSLog(@" arry count for images  from url %@",imgesArrayBeforeSearching );




                        //UI updates should be done on the main thread
                    });
                });         

        NSString *mediaURl=[[image_arr objectAtIndex:0]objectAtIndex:indexPath.row];
            NSLog(@" media thumb nil url  is %@",mediaURl);



        //cell.backgroundView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tentkotta_logo.png"]];
         cell.backgroundView.frame=CGRectMake(10, cell.backgroundView.frame.origin.y, cell.backgroundView.frame.size.width, cell.backgroundView.frame.size.height);
        [cell addSubview:title_lbl];
    }
    else
    {

        Media *media = [self.mediaList mediaAtIndex:(int)indexPath.row];
       cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[SimpleImageFetcher getDataFromImageURL:media.thumbnailURL]]];
  dispatch_queue_t myqueue = dispatch_queue_create("myqueue", NULL);

// execute a task on that queue asynchronously
        dispatch_async(myqueue, ^{
          NSURL *url = [NSURL URLWithString:[[NSString stringWithFormat:@"%@",media.thumbnailURL] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];;
            NSData *data = [NSData dataWithContentsOfURL:url];

            dispatch_async(dispatch_get_main_queue(), ^{
        UIImage*img = [UIImage imageWithData:data];
                NSArray *imgesArrayBeforeSearching=[NSArray arrayWithObjects:img, nil];

  NSLog(@" arry count for images  from url %@",imgesArrayBeforeSearching );                

                //UI updates should be done on the main thread
         });
        });


        NSLog(@" ******************** media title is  *******     %@",media.title);
       title_lbl.backgroundColor=[UIColor colorWithRed:0.752 green:0.752 blue:0.752 alpha:0.75];
        title_lbl.text=media.title;

        [cell addSubview:title_lbl];


    }

    return cell;
}

backgroundView是从远程服务器加载图像的imageView,您也应该将其放入块中