Rotation

See also 'Notifications' Default Rotation In the applicaitons Info.plist add the row: Initial Interface Orientation (UIInterfaceOrientation) Enabling Auto Rotation For A View Add to #ViewController.m //********** SHOULD AUTOROTATE ********** – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { //Set which orientations we allow if ( (toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) ) […]

Read More

UITabBarController

Applications use tab bar controllers to manage multiple distinct interfaces, each of which consists of any number of custom views and view controllers. For many applications the UITabBarController is used to provide all of the views the user sees. Useful Documentation iOS Reference Creating Multi UITabBarController Views Application Create an App as normal with the […]

Read More

Sideways Scrolling View

Create Sideways Scrolling View Of Multiple Pages This could be for a single page ap or as one of the views within say a UITabBarController //********** LOAD VIEW ********** – (void)loadView { //—– CREATE SCROLL VIEW —– CGRect frame = [[UIScreen mainScreen] applicationFrame]; UIScrollView *sv = [[[UIScrollView alloc] initWithFrame:frame] autorelease]; //Create Page View frame.origin.y = […]

Read More

Display An Image

Displaying An Image From A Design Time File Drag the image file into the resources folder of your project (from Finder into Xcode, not within Finder) Open the XIB file, drag an ImageView onto it. In the inspector attributes tab: Select the image file Set the mode In the inspector size tab: Set the red […]

Read More

Orientation Change Notification

Orientation Changed Notification Add to #AppDelegate.m didFinishLaunchingWithOptions //—– SETUP DEVICE ORIENTATION CHANGE NOTIFICATION —– UIDevice *device = [UIDevice currentDevice]; //Get the device object [device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app [nc addObserver:self //Add yourself as an observer selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification […]

Read More

Shake Detection

Motion events do not use the UIAccelerometer delegate.  The system determines motion events such as shake (by querying the accelerometer itself) and then sends the messages to the firstResponder application. Detecting Shake In Code Shake Start //********** MOTION BEGAN ********** – (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubtypeMotionShake) { NSLog(@”shake started”); } } //If […]

Read More

Timer General

In the .h file: NSTimer *showInfoBoxAfterDelayTimer1; In the .m file: myTimer1 = [NSTimer scheduledTimerWithTimeInterval:1.5 //seconds (use decimal places if requried) target:self selector:@selector(someMethodName) userInfo:nil repeats:NO]; //NO = fire only once //[myTimer1 fire]; //< Use this to trigger it immediately – (void)someMethodName { To Stop A Timer //You can use this, but if you do it to […]

Read More

Methods you can use with UIViewController

The following superclass methods may be added to a #ViewController.m file //******************************* //******************************* //********** LOAD VIEW ********** //******************************* //******************************* //View being loaded (happens only when view is initially loaded or reloaded in memory) – (void)loadView { [super loadView]; } //*********************************** //*********************************** //********** VIEW DID LOAD ********** //*********************************** //*********************************** //View has loaded (happens only when view […]

Read More

Adding A Button

Define in the .h file } – (IBAction)myButtonPressed:(id)sender; Create the function – (IBAction)myButtonPressed:(id)sender { } Connect In Interface Builder Right click, select ‘Touch Up Inside’ and drag button onto ‘Files Owner’, select myMethodName If you want to call the function from other code [self myButtonPressed:nil];

Read More