Skip to content

Instantly share code, notes, and snippets.

View amster's full-sized avatar
🎹

Amy Lee amster

🎹
View GitHub Profile
@amster
amster / gist:4455131
Created January 4, 2013 19:16
Hide/remove iPhone address bar (navigation bar) with the window.scrollTo() trick, but without moving the page perceptibly.
setTimeout( function(){ window.scrollTo(0, 0.1) }, 100 );
@amster
amster / YourViewController.m
Last active October 24, 2022 20:44
Load a UIWebView in iOS that can also load local resources like images, CSS, and JavaScript
// An example viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadWebView];
}
// The example loader
//
// Assumes you have an IBOutlet for the UIWebView defined: @property (strong, nonatomic) UIWebView *wv;
// Assuming SomePageViewController has a property called idx that holds its page number.
// Some number
#define MAX_PAGES 5
// Factory method
- (UIViewController *)viewControllerAtIndex:(int)i {
// Asking for a page that is out of bounds??
if (i<0) {
return nil;
// Assuming again pageViewController.viewControllers returns the
// NSArray of UIViewControllers and the object at index 0 is the
// current view controller---which has a property idx indicating
// the current page.
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
int currentPage = [[pageViewController.viewControllers objectAtIndex:0] idx];
return currentPage;
}
// Assuming property UIPageViewController *pager.
- (void)viewDidLoad
{
[super viewDidLoad];
// Create it.
self.pager = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
// Point the datasource back to this UIViewController.
- (void)goToPreviousPage:(id)sender {
int currentPage = [[self.pager.viewControllers objectAtIndex:0] idx];
// Don't do anything if we're already at the first page
if (currentPage =< 0) {
return;
}
// Instead get the view controller of the previous page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:(currentPage - 1)];
- (void)goToFirstPage:(id)sender {
int currentPage = [[self.pager.viewControllers objectAtIndex:0] idx];
// Don't do anything if we're already at the first page
if (currentPage =< 0) {
return;
}
// Instead get the view controller of the first page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:0];
{
"name": "YourAppHere",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2"
},
"dependencies": {
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec:{
build:{
command:"phonegap build ios",
stdout:true,
stderror:true
}
NSArray *allUrlsInDirectory = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsFolderURL = [allUrlsInDirectory lastObject];