Posts

Showing posts with the label iPhone

Creating Custom URL schemes in iOS/iPhone

Image
iPhone apps can also specify their own custom URL scheme (for example, myapp://doStuff). When might you want to use a custom URL scheme for your app? To transfer data from your app to your  another app To allow other apps (or even web pages) to call your app (and send data to it) To handle callbacks for custom authentication (such as OAuth ) and third party API's Implementing a Custom URL Scheme   The first step is to create a custom URL scheme – start by locating and clicking on the project info.plist in the Xcode Project Navigator. With the plist displayed in the right pane, right click on the list and select Add Row : From the list presented scroll down and select URL types .  Select URL Types for the new item. Once that's added, click the grey arrow next to "URL Types" to show "Item 0". Set your URL identifier to a unique string - something like com.yourcompany.yourappname.    After you've set the URL identifier, sele...

Disable iPhoto auto launch when connecting an iPhone / iPad

Image
Plug in your iPhone/iPad Open application "Image capture" Select your iPhone/iPad device Press the triangle in square symbol in the lower left corner. Choose "No application" in the drop-list under "Connecting this iPhone opens:"  

Add one minutes in NSDate

You can use dateByAddingTimeInterval. NSDate *currentDate = [NSDate date]; NSDate *date_plus_one_minute = [currentDate dateByAddingTimeInterval:60]; //60 seconds

Scroll UITextField above Keyboard in a UITableView OR UIScrollView in Swift and Objective C

In Objective C -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {     CGPoint pointInTable = [textField.superview convertPoint:textField.frame.origin toView:_tableview];     CGPoint contentOffset = _tableview.contentOffset;         contentOffset.y = (pointInTable.y - textField.inputAccessoryView.frame.size.height);         NSLog(@"contentOffset is: %@", NSStringFromCGPoint(contentOffset));        [_tableview setContentOffset:contentOffset animated:YES];        return YES; } -(BOOL)textFieldShouldEndEditing:(UITextField *)textField {     [textField resignFirstResponder];        if ([textField.superview.superview isKindOfClass:[UITableViewCell class]])     {         CGPoint buttonPosition = [textField convertPoint:CGPointZero  ...

typedef enum in Objective-C

Three things are being declared here: an anonymous enumerated type is declared, ShapeType is being declared a typedef for that anonymous enumeration, and the three names kCircle , kRectangle , and kOblateSpheroid are being declared as integral constants. Let's break that down.  In the simplest case, an enumeration can be declared as     enum tagname { ... }; This declares an enumeration with the tag tagname .  In C and Objective-C (but not C++), any references to this must be preceded with the enum keyword.  For example:     enum tagname x;  // declare x of type 'enum tagname'     tagname x;  // ERROR in C/Objective-C, OK in C++ In order to avoid having to use the enum keyword everywhere, a typedef can be created:     enum tagname { ... };     typedef enum tagname tagname;  // declare 'tagname' as a typedef for 'enum tagname' This can be simplified into one ...

Change the name of an iOS app

Image
Go to Targets in Xcode "Build Settings" on your project's targe Search for "Product Name" under "Packaging". Change the value of that what you want the new program name is going to be.

Disable ARC for a single file in a project

Image
It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files. You add compiler flags in Targets -> Build Phases -> Compile Sources . You have to double click on the right column of the row under Compiler Flags . You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box.

Custom fonts in iPhone

Image
Copy your font file into resources Add a key to your Info.plist file called UIAppFonts. ("Fonts provided by application) Make this key an array For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array Save Info.plist Now in your application you can simply call [UIFont fontWithName:@"CustomFontName" size:15] to get the custom font to use with your UILabels and UITextViews , etc…