Skip to content

Commit

Permalink
initial source commit
Browse files Browse the repository at this point in the history
  • Loading branch information
krukow committed Mar 5, 2012
1 parent 2a00c45 commit f9b1cca
Show file tree
Hide file tree
Showing 27 changed files with 2,754 additions and 0 deletions.
377 changes: 377 additions & 0 deletions LPSimpleExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions LPSimpleExample/LPAppDelegate.h
@@ -0,0 +1,17 @@
//
// LPAppDelegate.h
// LPSimpleExample
//
// Created by Karl Krukow on 07/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LPAppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) UITabBarController *tabBarController;

@end
105 changes: 105 additions & 0 deletions LPSimpleExample/LPAppDelegate.m
@@ -0,0 +1,105 @@
//
// LPAppDelegate.m
// LPSimpleExample
//
// Created by Karl Krukow on 07/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import "LPAppDelegate.h"

#import "LPFirstViewController.h"

#import "LPSecondViewController.h"

#import "LPThirdViewController.h"
#import "LPFourthViewController.h"

@implementation LPAppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;

- (void)dealloc
{
[_window release];
[_tabBarController release];
[super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1 = [[[LPFirstViewController alloc] initWithNibName:@"LPFirstViewController" bundle:nil] autorelease];
UIViewController *viewController2 = [[[LPSecondViewController alloc] initWithNibName:@"LPSecondViewController" bundle:nil] autorelease];

UIViewController *viewController3 = [[[LPThirdViewController alloc] initWithNibName:@"LPThirdViewController" bundle:nil] autorelease];

UIViewController *viewController4 = [[[LPFourthViewController alloc] initWithNibName:@"LPFourthViewController" bundle:nil] autorelease];

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3,viewController4, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"RESIGNACTIVE");
/*
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
{
NSLog(@"ENTERBACK");
/*
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
{
NSLog(@"ENTERFORE");
/*
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
{
NSLog(@"BECOMEACTIVE");
/*
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:.
*/
}

/*
// Optional UITabBarControllerDelegate method.
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
}
*/

/*
// Optional UITabBarControllerDelegate method.
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
{
}
*/

@end
18 changes: 18 additions & 0 deletions LPSimpleExample/LPFirstViewController.h
@@ -0,0 +1,18 @@
//
// LPFirstViewController.h
// LPSimpleExample
//
// Created by Karl Krukow on 07/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LPFirstViewController : UIViewController<UITextFieldDelegate>

@property (retain, nonatomic) IBOutlet UIButton *button;

@property (retain, nonatomic) IBOutlet UISwitch *uiswitch;
@property (retain, nonatomic) IBOutlet UISegmentedControl *segControl;
@property (retain, nonatomic) IBOutlet UITextField *textField;
@end
64 changes: 64 additions & 0 deletions LPSimpleExample/LPFirstViewController.m
@@ -0,0 +1,64 @@
//
// LPFirstViewController.m
// LPSimpleExample
//
// Created by Karl Krukow on 07/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import "LPFirstViewController.h"

@implementation LPFirstViewController

@synthesize button;
@synthesize uiswitch;
@synthesize segControl;
@synthesize textField;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"First", @"First");
self.tabBarItem.image = [UIImage imageNamed:@"first"];
}
return self;
}

-(void) viewDidLoad {
[super viewDidLoad];
self.uiswitch.isAccessibilityElement = YES;
self.uiswitch.accessibilityLabel = @"switch";

self.button.isAccessibilityElement = YES;
self.button.accessibilityLabel=@"login";
}

- (BOOL)textFieldShouldReturn:(UITextField *)_textField {
[_textField resignFirstResponder];
return YES;

}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}

- (void)dealloc {
[textField release];
[segControl release];

[uiswitch release];
[button release];
[super dealloc];
}
- (void)viewDidUnload {
[self setTextField:nil];
[self setSegControl:nil];

[self setUiswitch:nil];
[self setButton:nil];
[super viewDidUnload];
}
@end
14 changes: 14 additions & 0 deletions LPSimpleExample/LPFourthViewController.h
@@ -0,0 +1,14 @@
//
// LPFourthViewController.h
// LPSimpleExample
//
// Created by Karl Krukow on 23/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LPFourthViewController : UIViewController
@property (retain, nonatomic) IBOutlet UIWebView *webView;

@end
122 changes: 122 additions & 0 deletions LPSimpleExample/LPFourthViewController.m
@@ -0,0 +1,122 @@
//
// LPFourthViewController.m
// LPSimpleExample
//
// Created by Karl Krukow on 23/10/11.
// Copyright (c) 2011 Trifork. All rights reserved.
//

#import "LPFourthViewController.h"

@implementation LPFourthViewController
@synthesize webView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Fourth", @"Fourth");
self.tabBarItem.image = [UIImage imageNamed:@"second"];

}
return self;
}

- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
// NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:
// [NSURL URLWithString:@"http://www.google.com"]];

[self.webView loadHTMLString:@"<html><head><title>Google</title></head>\
<body><h1>Google header</h1>\
<div class='menu'><span class='heading'>Heading</span></div>\
A\
<ul>\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li>two\
<li>one\
<li style='display:none'>ten\
<li><a href='http://www.googl.com'>link</a>\
<li>Googles phase\
</ul></body>"

baseURL:[NSURL URLWithString:@"http://localhost:8080"]];

// Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
[self setWebView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSelector:@selector(findIt) withObject:nil afterDelay:2];
[self performSelector:@selector(clickIt) withObject:nil afterDelay:5];

}

-(void)findIt{

//
// NSArray* arr = [NDWebElement findElementsBy:kByXpath value:@"/html/body//*[contains(text(),'ten')]" maxCount:kFindEverything webView:self.webView];
// NDWebElement* el = [arr objectAtIndex:0];
// NSLog(@"eltext: %@",el.text);
// NSLog(@"eltagname: %@",el.tagName);
// NSLog(@"vis: %@", [el isDisplayed]?@"YES":@"NO");
// NSLog(@"RES: %@",arr);

}

-(void) clickIt {
// NSArray* arr = [NDWebElement findElementsBy:kByXpath value:@"/html/body//*[contains(text(),'link')]" maxCount:kFindEverything webView:self.webView];
// NDWebElement* el = [arr objectAtIndex:0];
// NSLog(@"eltext: %@",el.text);
// NSLog(@"eltagname: %@",el.tagName);
// NSLog(@"vis: %@", [el isDisplayed]?@"YES":@"NO");
// NSLog(@"RES: %@",arr);
// [el click];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}

- (void)dealloc {
[webView release];
[super dealloc];
}
@end

0 comments on commit f9b1cca

Please sign in to comment.