islahul
islahul

Reputation: 194

How to customize UIWebView?

Actually i have one table view ,when Select rowAtIndexPath then it load my webView and play my video, how to return from UIWebView to my tableView ?

 -(void)playButtonPressed1:(UIButton*)sender
 {


 Video *currentVideo= [[xmlParservideo videoNames] objectAtIndex:btn1.tag];


  NSLog(@"content============== %@", [currentVideo content2]);



 CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
 UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
 [webView setBackgroundColor:[UIColor greenColor]];
 NSString *urlString=currentVideo.content2;

 NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[[self view] addSubview:webView];  
//    [self.navigationController popViewControllerAnimated:YES];


NSLog(@"jointed2 jjjjjjjjj  %d",btn1.tag);

Upvotes: 2

Views: 391

Answers (3)

user1471790
user1471790

Reputation:

On didSelectRowAtIndexPath

videoViewController *newView = [videoViewController alloc]initWithNibName:@"videoViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];

and in your init method of the view controller create the webView programatically

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {

    self.title = @"Video Player";
UIWebView  *videoWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 290)];


[videoWebView setDelegate:self];

NSString *urlAddress = @"http://www.google.com"; 

NSURL *url = [NSURL URLWithString:urlAddress];


NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

[videoWebView loadRequest:requestObj];


[[self view] addSubview:videoWebView];  


}

return self;
}

Ok, Now just pop your view after completing your video

 [self.navigationController popViewControllerAnimated: NO];

Upvotes: 1

Zachary Christopoulos
Zachary Christopoulos

Reputation: 643

A workaround that may work is using this: [webView setHidden:YES];

This hides the webView from the view, so use that line of code whenever you want the webview to disappear. When you want it to return to the view, use this: [webView setHidden:NO];

Upvotes: 0

Melbourne
Melbourne

Reputation: 541

Place the Uiwebview in another view controller and push to it when a row is selected and when the video complete pop back to the tableview controller.

Upvotes: 1

Related Questions