Skip to content

Commit

Permalink
- webview loads page and prints document title
Browse files Browse the repository at this point in the history
  • Loading branch information
smistry-toushay committed Dec 4, 2013
1 parent 446559b commit bf59858
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 111 deletions.
26 changes: 2 additions & 24 deletions ApportableWebView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
AF51B6F5184F825A00AF89F0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AF51B6F3184F825A00AF89F0 /* InfoPlist.strings */; };
AF51B6F7184F825A00AF89F0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AF51B6F6184F825A00AF89F0 /* main.m */; };
AF51B6FB184F825A00AF89F0 /* APVAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AF51B6FA184F825A00AF89F0 /* APVAppDelegate.m */; };
AF51B6FE184F825A00AF89F0 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AF51B6FC184F825A00AF89F0 /* Main_iPhone.storyboard */; };
AF51B701184F825A00AF89F0 /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AF51B6FF184F825A00AF89F0 /* Main_iPad.storyboard */; };
AF51B704184F825A00AF89F0 /* APVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF51B703184F825A00AF89F0 /* APVViewController.m */; };
AF51B706184F825A00AF89F0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF51B705184F825A00AF89F0 /* Images.xcassets */; };
AF51B70D184F825A00AF89F0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF51B70C184F825A00AF89F0 /* XCTest.framework */; };
Expand Down Expand Up @@ -45,8 +43,6 @@
AF51B6F8184F825A00AF89F0 /* ApportableWebView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ApportableWebView-Prefix.pch"; sourceTree = "<group>"; };
AF51B6F9184F825A00AF89F0 /* APVAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APVAppDelegate.h; sourceTree = "<group>"; };
AF51B6FA184F825A00AF89F0 /* APVAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = APVAppDelegate.m; sourceTree = "<group>"; };
AF51B6FD184F825A00AF89F0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = "<group>"; };
AF51B700184F825A00AF89F0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = "<group>"; };
AF51B702184F825A00AF89F0 /* APVViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APVViewController.h; sourceTree = "<group>"; };
AF51B703184F825A00AF89F0 /* APVViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = APVViewController.m; sourceTree = "<group>"; };
AF51B705184F825A00AF89F0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -116,8 +112,6 @@
children = (
AF51B6F9184F825A00AF89F0 /* APVAppDelegate.h */,
AF51B6FA184F825A00AF89F0 /* APVAppDelegate.m */,
AF51B6FC184F825A00AF89F0 /* Main_iPhone.storyboard */,
AF51B6FF184F825A00AF89F0 /* Main_iPad.storyboard */,
AF51B702184F825A00AF89F0 /* APVViewController.h */,
AF51B703184F825A00AF89F0 /* APVViewController.m */,
AF51B705184F825A00AF89F0 /* Images.xcassets */,
Expand Down Expand Up @@ -232,9 +226,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AF51B701184F825A00AF89F0 /* Main_iPad.storyboard in Resources */,
AF51B706184F825A00AF89F0 /* Images.xcassets in Resources */,
AF51B6FE184F825A00AF89F0 /* Main_iPhone.storyboard in Resources */,
AF51B6F5184F825A00AF89F0 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -287,22 +279,6 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
AF51B6FC184F825A00AF89F0 /* Main_iPhone.storyboard */ = {
isa = PBXVariantGroup;
children = (
AF51B6FD184F825A00AF89F0 /* Base */,
);
name = Main_iPhone.storyboard;
sourceTree = "<group>";
};
AF51B6FF184F825A00AF89F0 /* Main_iPad.storyboard */ = {
isa = PBXVariantGroup;
children = (
AF51B700184F825A00AF89F0 /* Base */,
);
name = Main_iPad.storyboard;
sourceTree = "<group>";
};
AF51B715184F825A00AF89F0 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -475,6 +451,7 @@
AF51B71E184F825A00AF89F0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AF51B71F184F825A00AF89F0 /* Build configuration list for PBXNativeTarget "ApportableWebViewTests" */ = {
isa = XCConfigurationList;
Expand All @@ -483,6 +460,7 @@
AF51B721184F825A00AF89F0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
36 changes: 8 additions & 28 deletions ApportableWebView/APVAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,21 @@
// Copyright (c) 2013 Sandeep Mistry. All rights reserved.
//

#import "APVViewController.h"

#import "APVAppDelegate.h"

@implementation APVAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] init];

self.window.rootViewController = [[APVViewController alloc] init];

[self.window makeKeyAndVisible];

return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
4 changes: 3 additions & 1 deletion ApportableWebView/APVViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import <UIKit/UIKit.h>

@interface APVViewController : UIViewController
@interface APVViewController : UIViewController <UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;

@end
31 changes: 27 additions & 4 deletions ApportableWebView/APVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,39 @@ @interface APVViewController ()

@implementation APVViewController

- (void)loadView
{
self.view = [[UIView alloc] init];
self.view.backgroundColor = [UIColor darkGrayColor];
self.view.frame = CGRectMake(0, 0, 320, 480);
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

UIWebView *webView = [[UIWebView alloc] init];
webView.frame = CGRectMake(20, 20, 280, 440);
webView.delegate = self;
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:webView];
self.webView = webView;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.webView.allowsInlineMediaPlayback = YES;
self.webView.mediaPlaybackRequiresUserAction = NO;

NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=40rAtzemb-4"];
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:url];

[self.webView loadRequest:urlRequest];
}

- (void)didReceiveMemoryWarning
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
NSString *documentTitle = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];

NSLog(@"documentTitle = '%@'", documentTitle);
}

@end
2 changes: 0 additions & 2 deletions ApportableWebView/ApportableWebView-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>Main_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
26 changes: 0 additions & 26 deletions ApportableWebView/Base.lproj/Main_iPad.storyboard

This file was deleted.

26 changes: 0 additions & 26 deletions ApportableWebView/Base.lproj/Main_iPhone.storyboard

This file was deleted.

0 comments on commit bf59858

Please sign in to comment.