Pages

Wednesday, September 18, 2013

UITableView update Super View from Its Cell

I fought with UITable view and found that there should be some solution to update the Super view according to the selected cell from UITableView.

So i found the following Solution

Like we have added cells in UITableView like as below

NSArray *relatedContentArray = [[NSArray alloc]initWithArray:[self.somearray allObjects]];

RelatedContentTableView *relatedContentTableView = [[RelatedContentTableView alloc]initWithFrame:CGRectMake(0.0f, 88.0f, 280.0f, 460)];

relatedContentTableView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

relatedContentTableView.dataArray = self.relatedContentArray;
self.relatedContentTableView.selectedContentType = IndiewireRelatedContentFilms;
    

[self.relatedContentTableView.tableView reloadData];

Now we have to get the selected Cell in super view, So here is the solution of this

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    Article *aRelatedArticle = [self.dataArray objectAtIndex:indexPath.row];
    // article is the Varibale in SuperView Class and reloadSubviewsdata is function in Super View. TypeCasting should be like below
    ((ArticleDetailsView *)self.superview.superview).article = aRelatedArticle;

    [ ((ArticleDetailsView *)self.superview.superview) reloadSubviewsData];
}