user1436626
user1436626

Reputation: 21

How to increase the row height of particular cell in iphone and add buttons to that increased cell

I have an application where i am adding embedded youtube videos on tableview cell.On the left hand side of the tableview there is a checkbox to select the particular video .When i click on cell to play a video that particular video plays through the embedded video.But i want that when i click on the done button of youtube webview it should return to the same list page and the row height of that particular cell should increase by height with 2 buttons in it.When i click on the done button i am able to return to the same tableview page but the prob is the row height of the video that was played does not increase and buttons are also not visible.Please help me in solving this problem.Thanks.This is my code to return back to the same tableview page when the done button of video is clicked:

-(void)playVideo:(NSString *)urlString frame:(CGRect)frame
{
    NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: red;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>";
    NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
    videoView = [[UIWebView alloc] initWithFrame:frame];
    [videoView loadHTMLString:html baseURL:nil];


}


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

        }


        ArchiveModal *AM = (ArchiveModal*)[DatafromArchModal objectAtIndex:indexPath.row] ;


        NSLog(@"%i",AM.VideoId);
        [self playVideo:AM.ArchUrl frame:CGRectMake(60, 20, 200, 100)];
        //this function is for embedding video and playing video 
             [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(windowNowVisible:)
         name:UIWindowDidBecomeVisibleNotification
         object:self.view.window
         ];


        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(windowNowHidden:)
         name:UIWindowDidBecomeHiddenNotification
         object:self.view.window
         ];




}

-(void)didselectrowAtindexPath
{

    [self playVideo:AM.ArchUrl frame:CGRectMake(60, 20, 200, 100)];

}   

//this is the notification called when the done button is cliked.Here i am calling the same tableview list page when the done button is cliked.But i want that when the done button is clicked the same page should be called but the row height of that particular cell which has played should increase in height and 2 buttons should also be added to that particular row.

Upvotes: 0

Views: 347

Answers (1)

Krunal
Krunal

Reputation: 6490

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   [self addButton];
   return 50; //returns height of row
}    

creates Button:

-(void)addButton
{
  UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  [button addTarget:self action:@selector(callYourMethod:) forControlEvents:UIControlEventTouchDown];
  [button setTitle:@"Show View" forState:UIControlStateNormal];
  button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
  [view addSubview:button];
  [button release];
}

Upvotes: 1

Related Questions