我有一个UITableView
从后端加载的歌曲数量(实际上是歌曲的网址)。这些正在形成JSON
格式。现在我的问题是当歌曲数量增加时,表格会卡住。很难滚动。那么我怎样才能避免这种情况呢?
我正在加载主视图顶部的视图。在主视图中viewDidLoad
arrSongList=[[NSMutableArray alloc]init];
arrSongList=[ws GetSongs];`
然后有一个菜单来选择歌曲选项。当我单击该菜单单元格时,它会加载歌曲视图。用于加载歌曲视图
-(void)getAllSongsAndReloadTable :(id)sender//1
{
[viewDisplayArea addSubview:viewSongs];
[self flipView : viewDisplayArea: viewDisplayArea : UIViewAnimationTransitionFlipFromLeft];
[progressAlert dismissWithClickedButtonIndex:0 animated:YES];
}
ViewSongs
查看有歌表。它以这种方式加载
这是为了numberOfRowsInSection
else if (tableView.tag==4)
{
return [arrSongList count];
}
这是为了cellForRowAtIndexPath
else if (tableView.tag==4)//All Songs
{
cell4 =nil;
if (cell4 == nil) {
NSArray *nib =[[NSBundle mainBundle]loadNibNamed:@"SongCell" owner:self options:nil];
cell4=[nib objectAtIndex:0];
}
[cell4 setSelectionStyle:UITableViewCellSelectionStyleNone];
cell4.lblSong.text=[[arrSongList objectAtIndex:indexPath.row] valueForKey:@"SONGTITLE"];
cell4.lblArtist.text=[[arrSongList objectAtIndex:indexPath.row] valueForKey:@"ARTISTNAME"];
NSString *imgUrl=[[arrSongList objectAtIndex:indexPath.row]valueForKey:@"SONGIMG"];
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString: imgUrl]];
UIImage *img = [[UIImage alloc] initWithData:data];
cell4.imgSong.image=img;
NSString *imgUrlLarge=[[arrSongList objectAtIndex:indexPath.row]valueForKey:@"SONGIMGLARGE"];
NSData *dataLarge=[NSData dataWithContentsOfURL:[NSURL URLWithString: imgUrl]];
UIImage *imgLarge = [[UIImage alloc] initWithData:dataLarge];
cell4.imgSongLarge=[[UIImageView alloc]init];
cell4.imgSongLarge.image=imgLarge;
[cell4.btnTick addTarget:self action:@selector(tickButtonTapped:) forControlEvents:UIControlEventTouchUpInside] ;
[cell4.btnAddtoMyList addTarget:self action:@selector(topLeft:) forControlEvents:UIControlEventTouchUpInside];
return cell4;
}