Present SWRevealViewController When WebView link is tapped - ios

I have a MainViewController with webViewMain.
The following functions checks if a link is ready to send a user to a certain directory in my webview.
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *path = [url path];
if ([path isEqualToString:#"/mypath/"]){
NSLog(path);
return NO; }
return YES;
}
That code is all working fine. However, when the link is tapped I want to show my SWReveal Sidebar (sw_rear) and display the URL in that ViewController.
How can I do this?

I'm not understanding your scenario 100%, but with luck these steps will get you where you need to be.
Fetch the revealer and the rear view controller that holds your target webview:
SWRevealViewController *revealer = self.revealViewController; // 'self' here should be a view controller
UIViewController *rearVC = revealer.rearViewController;
UIWebView *webview = rearVC.webView;
Load up your URL:
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];

Related

Press button fill textfield inside UIWebview For iOS application

i used normal code to link this url Front Page URL and on pressing button "Mulai" Its not working but the second button works and loads another page.
Here is the code i used :
_WebViewContent.delegate = self;
NSURL *url = [NSURL URLWithString:#"http://www.curhats.com/mobileapp/"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_WebViewContent setScalesPageToFit:YES];
[self.WebViewContent loadRequest:request];
The Button Mulai This is mulai page
Please someone help me

UIWebView does not load full content from an url

I have a UIWebView where i load a url. But it does not load full content. I have checked all possible forums for solution but couldn't find a breakthrough yet. Any help would be really appreciated? You can try out the below url yourself. Basically, the url is supposed to contain html5 content/player.
-(void)loadPlayerUrl
{
activityIndicatorView.hidden = NO;
NSURL* nsUrl = [NSURL URLWithString:#"http://watch.nimbletv.com/tv"]
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
[self.playerWebView loadRequest:request];
}
However, this works perfectly in safari or any other browser.
You should create ViewControllerWebPage
Then
- (void)viewDidLoad
{
[super viewDidLoad];
self.screenName = #"Info Ekran";
NSURL *mobileCreaURL = [NSURL URLWithString:#"http://mobilecrea.com/"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:mobileCreaURL];
[mobileCrea loadRequest:myRequest];
}
Also create new view, select your new custom class (ViewControllerWebPage) and than create UIWebView

iOS 7 UIWebView inconsistent Loading

In my project I have 2 UIWebViews that are IBOutlets and created in the main.storyboard.
One I load by calling a method on ViewDidAppear. It appears perfectly and hits all it's delegate methods. We will call this ViewA
The other is supposed to be Hidden and appear and load when the user taps a button. We will call this ViewB. But once I submit the request, nothing happens, none of the delegate methods get called.
ViewA loads perfectly. If I try to load ViewB on ViewDidAppear, it also loads.
EDIT: Moving the ViewA and ViewB load method calls to the ButtonPress method calls both successfully.
EDIT: Code
-(void)loadCarouselWebView //ViewA
{
NSString *urlString = [NSString stringWithFormat:#"%#%#",[[JSONReader sharedInstance] baseURLToLoad:environmentURLPublicKey],[[JSONReader sharedInstance] URLToLoad:kCarouselURLkey]];
NSURL *url = [NSURL URLWithString: urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
self.carouselWebView.delegate = self;
[self.carouselWebView loadRequest: requestObj];
}
-(void)loadFullWebView:(int)index //ViewB
{
NSString *gameURL;
switch (index) {
case 1:
gameURL = game1Constant;
break;
case 2:
gameURL = game2Constant;
break;
case 3:
gameURL = game3Constant;
default:
break;
}
NSString *urlString = [NSString stringWithFormat:#"%#%#",[[JSONReader sharedInstance] baseURLToLoad:environmentURLKey],[[JSONReader sharedInstance] URLToLoad:gameURL]];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
self.fullWebView.delegate = self;
[self.fullWebView loadRequest: requestObj];
}
- (IBAction)gameButtonPushed:(id)sender {
[[self fullWebView] setHidden:NO];
[[self backNavButton] setHidden:NO];
[self loadFullWebView:[sender tag]];
[self loadCarouselWebView];//Added for debugging
}
EDIT: ONLY Loading ViewB on button tap works. If I add Load ViewA on ViewDidAppear then ViewB will not load.
In a surprise twist, there is nothing wrong with the UIWebView.
It was my fault for not reading the code carefully enough.
Someone coded a one time counter into the shouldStartLoadingRequest delegate method that I missed. So only one request was allowed to load.
Thats like 2 days burned there, great stuff! >:E

How to load a UIWebView when click a button in another view in ios

I want to create an ios application which incuding a UIWebview. I saw so many tutorials that saying how to load webview when start the application. But what I want is when user click on a link in one View,the web page should be loaded in seperate View. This is the code in my button click event.
`
-(IBAction)visitWeb:(id)sender{
web *wb=[[web alloc]initWithNibName:nil bundle:nil];
[self presentModalViewController:wb animated:YES];
[wb release];}
This is in web
`
- (void)viewDidLoad {
NSString *urlAddress = #"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
[super viewDidLoad]; }
But it not display anything. Just display the empty UIWebView What is the reason for it.plz give me a solution with the code.
Thanks,

Refer to another tab bar within iOS application

I have a tab bar application with a login screen on a UIWebView and then when the user is logged in all the other tabs are able to use the same login.
The login button is also on the website and I have no control over that code.
Now if a user is not logged in then the other tabs give an error, but I was wondering if i could do an if statement, comparing the active tab to the first, to see if the login page is displayed. so the idea would look like this.
if(tab bar 1 == index.html) {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"index" ofType:#"html"]isDirectory:NO]]];
else{
NSString *urlAddress = #"website that is requested";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
What do I put in the () after the if statement?
Cheers
`[[self.tabBarController viewControllers] objectAtIndex:0]; will return the view controller for the first tab. Make the web view a property of the view controller. Then:
UIViewController *loginViewController = [[self.tabBarController viewControllers] objectAtIndex:0];
UIWebView *loginWebView [loginViewController webView];
NSString *currentURL = [loginWebView stringByEvaluatingJavaScriptFromString:#"window.location"];
if (currentURL == someURL) {
...
}

Resources