Tutorial details

Universal Applications | App Code for Sale | Preview

Universal Applications | iOS Tutorial

How to create universal applications

Overview PAGE TOP

Reference: http://www.geekylemon.com/xcode-universal-application

In this tutorial i will be showing you how to create universal applications

Features:

  • 2 Buttons
  • 2 Labels

Every application works both on iPhone and iPad and by making your application universal you double your target audience by simply detecting what device the user is using.

ViewController.h PAGE TOP

@interface ViewController : UIViewController {
IBOutlet UILabel *Label;
}
-(IBAction)SwitchView:(id)sender;

@end

ViewController.m PAGE TOP

#import "ViewController.h"
#import "SecondView.h"

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
Label.text = @"i am an iPhone";

} else {
Label.text = @"i am an iPad";
}
}

-(IBAction)SwitchView:(id)sender {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
SecondView *second = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
} else {
SecondView *second = [[SecondView alloc] initWithNibName:@"SecondView_iPad" bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
}

@end

SecondView.h PAGE TOP

@interface SecondView : UIViewController {
IBOutlet UILabel *label;
}
- (IBAction)goBack:(id)sender;

@end

SecondView.m PAGE TOP

#import "SecondView.h"

@implementation SecondView

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
label.text = @"i am an iPhone";
} else {
label.text = @"i am an iPad";
}
}

- (IBAction)goBack:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}
@end

Reference PAGE TOP

http://www.geekylemon.com/xcode-universal-application

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.