I have made an iOS app to load a simple UIWebView *mWeb
.
Once the app starts it loads my originalURL
.
At the bottom of the UI, I have a UIButton
placed *btnHome
.
When I click this UIButton
I want it load another URL *loadNextURL
.
However something's not working on my end... HELP!
Here's the code for my myViewController.h
file.
#import "myViewController.h"
@interface myViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btnHome;
@property (weak, nonatomic) IBOutlet UIWebView *mWeb;
@end
@implementation myViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *originalURL = @"http://myOriginalLink";
NSURL *url = [NSURL URLWithString:originalURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_mWeb loadRequest:requestObj];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (IBAction)btnHome:(id)sender
{
NSString *loadNextURL = @"http://link2";
NSURL *url2 = [NSURL URLWithString:loadNextURL];
NSURLRequest *reqObj = [NSURLRequest requestWithURL:url2];
[_mWeb loadRequest:reqObj];
}
@end
Well there can be two problems, first check that your action method is bound to the button or not. Second the url in stringVariable loadNextUrl is valid or not.
Now how to check the url is valid or not, just copy the url and paste into the browser. If the link does not open then the url is not valid. So for that pass the valid url in the string variable and then try.