UIImagePicker is the simple way to record video. It is a portrait only camera (although the image obviously turns when the device is turned, the button bar is portrait only) Add these delegates in the .h file @interface MyViewController_iPhone : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> //-ADD THESE { Then in your .m file //***************************************** //***************************************** //********** RECORD […]
All posts by
Adding Icon Badge
Adding A Badge [[UIApplication sharedApplication] setApplicationIconBadgeNumber:99];
Casting General
An example casing objects sent with an ID to the class they actually are NSInteger MyCompareFunction(id arg1, id arg2, void *arg3) { return [[(MyClassName *)arg1 SomeObjectInClass] compare: [(MyClassName *)arg2 SomeObjectInClass]]; }
Sorting Arrays
Basic Array Sort In Ascending Order [SomeArrayName sortUsingSelector:@selector(compare:)]; SomeArrayName = [SomeArrayName sortedArrayUsingSelector:@selector(compare:)]; Sorting In Descending Order NSSortDescriptor *sortOrder = [NSSortDescriptor sortDescriptorWithKey: @”self” ascending: NO]; [SomeArrayName sortUsingDescriptors:[NSArray arrayWithObject: sortOrder]]; SomeArrayName = [SomeArrayName sortedArrayUsingDescriptors:[NSArray arrayWithObject: sortOrder]]; Sorting Classes This can be used with classes that contain a varaible or object you want to sort the entire class […]
In App Purchases General
Good resources http://maniacdev.com/2010/02/in-app-purchase-tutorials/
Modal View Controller
To Show A View Controller Modally #ViewController_iPhone *vc1 = [[#ViewController_iPhone alloc] init]; [self presentModalViewController:vc1 animated:YES]; //[ptabBarController presentModalViewController:vc1 animated:YES]; //An alternative [vc1 release]; To Close It //Close this view [self dismissViewControllerAnimated:YES completion:nil]; Notes Use popViewControllerAnimated when you've used pushViewController:animated: Use dismissModalViewControllerAnimated when you've used presentModalViewController:animated:
Changing Button Properties
Changing In A Method Called By A Button – (IBAction)MyButton:(id)sender { UIButton *ThisButton = (UIButton *)sender; [ThisButton setTitle:@”1234″ forState:UIControlStateNormal]; ThisButton.titleLabel.font = [UIFont systemFontOfSize:9]; } Changing From Anywhere In the .h file add this IBOutlet UIButton *MyButton; Link the button in interface builder If your View could get unloaded you must release objects you’ve created (or […]
Color General
Set Background Color [[self view] setBackgroundColor:[UIColor blueColor]]; Defined Colours MyTextBox.textColor = [UIColor darkGrayColor]; Bespoke Colour //Set to RGB value myText.textColor = [UIColor colorWithRed:150/255.0 green:200/255.0 blue:80/255.0 alpha:1]; Greyscale Colour myText.textColor = [UIColor colorWithWhite:0.5 alpha:1]; //1=white, 0.5=50%, 0=black Transparent Colour MyTextBox.textColor = [UIColor clearColor];
Global Classes
The best way to create a global class is to create a Singleton Instance. The Apple description of this is here. However Matt Gallagher has a great page on it here and this example is based on downloading his marco header file to simplify implementation. Create a class called AppMain as normal. Copy Matt’s SynthesizeSingleton.h […]
Date Picker Control
Example Of Use Declaring in #ViewController.h file IBOutlet UIDatePicker *MyDatePicker; Releasing in #ViewController.m file //********** VIEW DID UNLOAD ********** – (void)viewDidUnload { [super viewDidUnload]; [MyDatePicker release]; MyDatePicker = nil; } //********** DEALLOC ********** – (void)dealloc { [MyDatePicker release]; [super dealloc]; } Connecting in Interface Builder Add the date picker to the view Right click Files […]