//
//  ViewController.m
//  RJMWordpressBlog
//
//  Created by pgAgent on 7/10/2014.
//  Copyright (c) 2014 RJM Programming. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize wv1;

//method for going backwards in the webpage history
-(void)backMethod:(UIButton*)button {
    [wv1 goBack];
}

//method for going forward in the webpage history
-(void)forwardMethod:(UIButton*)button {
    [wv1 goForward];
}

- (void)viewDidLoad
{
    UIButton * btnb = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btnb.frame = CGRectMake(0, 0, 100, 50);
    [btnb setTitle:@"Back" forState:UIControlStateNormal];
    [btnb addTarget:self action:@selector(backMethod:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnb];

    UIButton * btnf = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btnf.frame = CGRectMake(400, 0, 100, 50);
    [btnf setTitle:@"Forward" forState:UIControlStateNormal];
    [btnf addTarget:self action:@selector(forwardMethod:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnf];

    
	// Do any additional setup after loading the view, typically from a nib.
    NSString *strWebsiteUlr;
    strWebsiteUlr = [NSString stringWithFormat:@"http://www.rjmprogramming.com.au/wordpress/"];
    // Load URL
    
    //Create a URL object.
    NSURL *url = [NSURL URLWithString:strWebsiteUlr];
    
    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    
    //Load the request in the UIWebView.
    [wv1 loadRequest:requestObj];
    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        wv1.scrollView.clipsToBounds = YES; //normal;
        wv1.scrollView.scrollEnabled = YES;
        wv1.scrollView.pagingEnabled = YES;
    }
    else
    {
        wv1.scrollView.clipsToBounds = YES;
        wv1.scrollView.scrollEnabled = YES;
        wv1.scrollView.pagingEnabled = YES;
    }
    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        wv1.scrollView.autoresizesSubviews = YES; //normal; //YES; //NO;
        //wv1.scrollView.zoomScale = 0.5;
        wv1.scalesPageToFit = YES; //NO;
    }
    else
    {
        wv1.scrollView.autoresizesSubviews=YES;  //NO; //YES
        wv1.scalesPageToFit = YES;
    }
    [super viewDidLoad];
   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
