- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return arrVideos.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
VideoListingCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[VideoListingCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//fetch current object
NSMutableDictionary *dict = [[arrVideos objectAtIndex:indexPath.row] mutableCopy];
//set values
if ([[dict valueForKey:kCaption] isEqual:[NSNull null]])
{
cell.lblCaption.text =@"No caption";
}
else
{
cell.lblCaption.text = [dict valueForKey:kCaption];
}
[cell.acivityView startAnimating];
BOOL isNonEmpty = [CommonMethods isNonEmptyString:[dict valueForKey:kThumbnailURL]];
if (isNonEmpty)
{
NSString *strUrl = [dict valueForKey:kThumbnailURL];
[cell.imgThumbnail sd_setImageWithURL:[NSURL URLWithString:strUrl] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[cell.acivityView stopAnimating];
}];
}
else
{
[cell.imgThumbnail setImage:[UIImage imageNamed:@"img1"]];
[cell.acivityView stopAnimating];
}
[cell.imgThumbnail setClipsToBounds:YES];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//fetch selected object
NSMutableDictionary *dict = [[arrVideos objectAtIndex:indexPath.row] mutableCopy];
ExportVideoVC *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"ExportVideoVC"];
obj.dictPost = [dict mutableCopy];
[self presentViewController:obj animated:YES completion:nil];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 124;
}
#pragma mark - webservice calls
-(void)fetchAllVideos
{
//show progress hud
[SVProgressHUD showWithStatus:kPleaseWait maskType:2];
//prepare url
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@" video url ", kURL, kMediaType]];
//ws call
[[ServerCalls sharedObject] executeRequest:url withData:nil method:kGET completionBlock:^(NSData *data, NSError *error) {
if (error)
{
ShowAlertWithTitle(@"Please try again later", nil, kOK);
//reload tableview
[tblVideos reloadData];
}
else if (data)
{
NSDictionary *responseData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
BOOL isSuccess = ![[responseData allKeys] containsObject:kMessage];
if (isSuccess)
{
arrVideos = [[responseData valueForKey:kQuickSpots] mutableCopy];
}
else
{
ShowAlertWithTitle(@"Please try again later", nil, kOK);
}
}
//reload tableview
[tblVideos reloadData];
[SVProgressHUD dismiss];
}];
}
这可能对你有帮助