Sorry for the inconvenience.
I want to arrange the URLs in an array in TableView, but it doesn't work.
I don't know how to solve this problem because it's not the URL taken from the array urls
, but the array urls
is arranged in one cell.
Could you please let me know if anyone knows?
Thank you for your cooperation.
Thumbnail images created by other classes are now displayed.
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell* cell= [tableView requestReusableCellWithIdentifier:@"movieCell" forIndexPath:indexPath];
NSURL*url1 = [NSURL URLWithString:@"
";
NSURL*url2 = [NSURL URLWithString:@" "];
NSArray*urls = [NSArray arrayWithObjects: url2, url1,nil];
NSLog(@"urls count:%@",urls);
for (inti=0;i<_urls.count;i++)
{
MPMoviePlayerController*moviePlayerController=[MPMoviePlayerController alloc] initWithContentURL:_urls[i]];
MoviePlayerController setScalingMode: MPMovieScalingModeAspectFit;
// [moviePlayerController.view setFrame: CGRectMake(0,0,320,170)];
if([self.movieList indexOfObject:moviePlayerController] == NSNotFound) {
[self.movieList insertObject:moviePlayerController atIndex:indexPath.row];
}
}
return cell;
}
cellForRowAtIndexPath is the number of dataSources to be displayed.
Therefore, there is no need to loop dataSource (urls in this case) in cellForRowAtIndexPath.
It is better to keep uri as an instance variable in advance and get and set the value for each line.
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell* cell= [tableView requestReusableCellWithIdentifier:@"movieCell" forIndexPath:indexPath];
// Keep URI in cells 本来 Originally, UITableViewCell does not have uri property.
cell.uri=_urls [indexPath.row];
return cell;
}
I think this area is a natural knowledge to use UITableView, so
I'm afraid it's intrusive, but I recommend you check it out.
ありますThere are many blogs with explanations of easy-to-understand samples.
--------------
It may be a little off the point of this question, but there was a description in the answer that might cause misunderstanding, so please allow me to correct it a little.
cellForRowAtIndexPath is the number of dataSources to be displayed.
I wrote briefly, but it's actually different.
I'll skip the detailed explanation, but UITableView helps you use memory efficiently.
Cells are being reused.
Therefore, instead of saying, "There are 100 dataSource, call cellForRowAtIndexPath 100 times at initial display and end it," it is called many times to match the scroll in TableView even after displaying the screen.
If numberOfRowsInSection returns the appropriate value,
IndexPath does not overflow from dataSource, so there is no problem with the following:
_urls [indexPath.row]
© 2024 OneMinuteCode. All rights reserved.