SlideShare a Scribd company logo
1 of 36
Download to read offline
U"lising View Controllers
         Daniel Tull
A Small Plug...
Sky+          Weather Maps
What is a view controller?



A class to manage user 
interface logic for a view.
What is a view controller?


            Provides the structure and 
            functionality of the Apple‐
            developed UI design 
            patterns.
What is a view controller?
Navigation Bar               Title

Navigation 
Back Button                Bar Button


Table View


  Tab Bar
                      ‘More’ Tab Item
Why use a view controller?

Almost zero code to use Tab and Navigation 
Bars. 
Use to display a modal view (like a login page).
Get a message when the orientation of the device 
changes so you can handle landscape mode.
Memory warnings enable you to avoid crashing 
out due to too many views in memory.
Naviga"on Controller


Allows navigation 
through a hierarchy of 
view controllers.

You don’t need to write 
(much) code for it.
Naviga"on Controller


Allows navigation 
through a hierarchy of 
view controllers. 

You don’t need to write 
(much) code for them.
Naviga"on Controller


[self.navigationController pushViewController:vc 
animated:YES];

[self.navigationController 
popViewControllerAnimated:YES]; 
Tab Bar Controllers

Allow quick switching of 
view controllers.

You don’t need to write 
(much) code for them; 
Send it an array of view 
controllers and it works!
Tab Bar Controllers

Allow quick switching of 
view controllers.

You don’t need to write 
(much) code for them; 
Send it an array of view 
controllers and it works!
Tab Bar Controllers

Allow quick switching of 
view controllers.

You don’t need to write 
(much) code for them; 
Send it an array of view 
controllers and it works!
Subclassing UIViewController

Implement initWithNibName:bundle: if you need to  
handle any speciOic logic when creating your view 
controller.
This Oinds the view XIB of the provided details and 
loads it for use.
The File Owner of the XIB is the view controller 
subclass, so we set that in Interface Builder.
Subclassing UIViewController
Subclassing UIViewController

Create an init method, because it’ll make life easier.


‐(id)init {
    return [self initWithNibName:@“MyView” bundle:nil];
}


But still use the initWithNibName:bundle: method 
in your subclass rather than calling super!
A View XIB for view controllers




 Connecting the view controller’s view property to 
 the UIView in Interface Builder.
A View XIB for view controllers


 Setting the view’s 
 autosizing property to 
 Olexible width and height 
 will allow use inside any 
 view controller structure. 
Autorota"on

If you have set the view to Olexible width and 
height, it will resize to the new dimensions.

‐ (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

Giving subviews correct autoresizingMask 
properties will allow you to go landscape 
automatically.
Autorota"on
Autorota"on
Autorota"on
Autorota"on
Autorota"on
Autorota"on
Autorota"on
Autorota"on
Crea"ng IBOutlets

The nib loading mechanism uses accessors, so you 
should declare outlets in property delcarations:

@interface MyViewController : UIViewController {

    UIView *subView;

}

@property (nonatomic, retain) IBOutlet UIView *aSubview;

@end
Handling Memory Warnings

          UIViewController

      didRecieveMemoryWarning




               view
Handling Memory Warnings

          UIViewController

      didRecieveMemoryWarning   setView:
                                  nil
              setView:


               view
Handling Memory Warnings

          UIViewController

      didRecieveMemoryWarning   setView:
                                  nil
              setView:


               view
Handling Memory Warnings

                     MyViewController




                          view
                    UIView *aSubview; 
     UIImage *image1;  UIBuQon *buQon1; UILabel *label1;  UIView *subview; 
     UIImage *image2;  UIBuQon *buQon2; UILabel *label2;  DTGridView *grid; 
     UIImage *image3;  UIImage *buQon3;  UILabel *label3;  UITableView *table; 
      UISlider *slider; UIWebView *webView;  UISegmentedControl *segControl;
Handling Memory Warnings

                     MyViewController

          didRecieveMemoryWarning




                          view
                    UIView *aSubview; 
     UIImage *image1;  UIBuQon *buQon1; UILabel *label1;  UIView *subview; 
     UIImage *image2;  UIBuQon *buQon2; UILabel *label2;  DTGridView *grid; 
     UIImage *image3;  UIImage *buQon3;  UILabel *label3;  UITableView *table; 
      UISlider *slider; UIWebView *webView;  UISegmentedControl *segControl;
Handling Memory Warnings

                     MyViewController

          didRecieveMemoryWarning                                                 setView:
                                                                                    nil
                                setView:


                          view
                    UIView *aSubview; 
     UIImage *image1;  UIBuQon *buQon1; UILabel *label1;  UIView *subview; 
     UIImage *image2;  UIBuQon *buQon2; UILabel *label2;  DTGridView *grid; 
     UIImage *image3;  UIImage *buQon3;  UILabel *label3;  UITableView *table; 
      UISlider *slider; UIWebView *webView;  UISegmentedControl *segControl;
Handling Memory Warnings

                     MyViewController

          didRecieveMemoryWarning                                                 setView:
                                                                                    nil
                                setView:


                          view
                    UIView *aSubview; 
     UIImage *image1;  UIBuQon *buQon1; UILabel *label1;  UIView *subview; 
     UIImage *image2;  UIBuQon *buQon2; UILabel *label2;  DTGridView *grid; 
     UIImage *image3;  UIImage *buQon3;  UILabel *label3;  UITableView *table; 
      UISlider *slider; UIWebView *webView;  UISegmentedControl *segControl;
Handling Memory Warnings
‐ (void)setView:(UIView *)aView {
    if (!aView)
        self.someSubview = nil;
    
    [super setView:aView];
}

‐ (void)dealloc {
    [someSubview release];
    someSubview = nil;
}
Thank You
dt@danieltull.co.uk

More Related Content

Viewers also liked

小樽オススメグルメ情報
小樽オススメグルメ情報小樽オススメグルメ情報
小樽オススメグルメ情報
Yutaka Ogasawara
 
TECHNOLOGY, FINAL
TECHNOLOGY, FINALTECHNOLOGY, FINAL
TECHNOLOGY, FINAL
Rachel
 
Worldhistory Rachel
Worldhistory RachelWorldhistory Rachel
Worldhistory Rachel
Rachel
 
RM N° 0558 2013-ed
RM N° 0558 2013-edRM N° 0558 2013-ed
RM N° 0558 2013-ed
olguin01
 
RM N° 0558 2013-ed
RM N° 0558 2013-edRM N° 0558 2013-ed
RM N° 0558 2013-ed
olguin01
 
Brave New World - Technology
Brave New World - TechnologyBrave New World - Technology
Brave New World - Technology
Rachel
 
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
olguin01
 

Viewers also liked (14)

小樽オススメグルメ情報
小樽オススメグルメ情報小樽オススメグルメ情報
小樽オススメグルメ情報
 
Sprk2012 懇親会を支えるチーム酒
Sprk2012 懇親会を支えるチーム酒Sprk2012 懇親会を支えるチーム酒
Sprk2012 懇親会を支えるチーム酒
 
TECHNOLOGY, FINAL
TECHNOLOGY, FINALTECHNOLOGY, FINAL
TECHNOLOGY, FINAL
 
Worldhistory Rachel
Worldhistory RachelWorldhistory Rachel
Worldhistory Rachel
 
Reverse Mortgage
Reverse MortgageReverse Mortgage
Reverse Mortgage
 
RM N° 0558 2013-ed
RM N° 0558 2013-edRM N° 0558 2013-ed
RM N° 0558 2013-ed
 
RM N° 0558 2013-ed
RM N° 0558 2013-edRM N° 0558 2013-ed
RM N° 0558 2013-ed
 
Brave New World - Technology
Brave New World - TechnologyBrave New World - Technology
Brave New World - Technology
 
Designing For The iPhone Developer
Designing For The iPhone DeveloperDesigning For The iPhone Developer
Designing For The iPhone Developer
 
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
Rm023 2015-minedu-contratodocente2015-150114175352-conversion-gate01
 
16 Shot Photo Essay
16 Shot Photo Essay16 Shot Photo Essay
16 Shot Photo Essay
 
4 cinetica quimica
4 cinetica quimica4 cinetica quimica
4 cinetica quimica
 
Issue Management Plan
Issue Management PlanIssue Management Plan
Issue Management Plan
 
Change Management Strategy
Change Management StrategyChange Management Strategy
Change Management Strategy
 

Similar to Utilising View Controllers

iPhoneOS3.1でのカメラAPIについて
iPhoneOS3.1でのカメラAPIについてiPhoneOS3.1でのカメラAPIについて
iPhoneOS3.1でのカメラAPIについて
Kyosuke Takayama
 
iOS 7 Blur Views
iOS 7 Blur ViewsiOS 7 Blur Views
iOS 7 Blur Views
Gerald Kim
 
아이폰강의(5) pdf
아이폰강의(5) pdf아이폰강의(5) pdf
아이폰강의(5) pdf
sunwooindia
 
Heat on Wed.(ヒートオンウェンズディ)! Vol.1
Heat on Wed.(ヒートオンウェンズディ)! Vol.1Heat on Wed.(ヒートオンウェンズディ)! Vol.1
Heat on Wed.(ヒートオンウェンズディ)! Vol.1
Noriyuki Nonomura
 

Similar to Utilising View Controllers (20)

I os 11
I os 11I os 11
I os 11
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Many
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
IOS APPs Revision
IOS APPs RevisionIOS APPs Revision
IOS APPs Revision
 
iPhoneOS3.1でのカメラAPIについて
iPhoneOS3.1でのカメラAPIについてiPhoneOS3.1でのカメラAPIについて
iPhoneOS3.1でのカメラAPIについて
 
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
Session 15  - Working with Image, Scroll, Collection, Picker, and Web ViewSession 15  - Working with Image, Scroll, Collection, Picker, and Web View
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
 
iOS: View Controllers
iOS: View ControllersiOS: View Controllers
iOS: View Controllers
 
Swf2 ui
Swf2 uiSwf2 ui
Swf2 ui
 
PhotoFlipCardView
PhotoFlipCardViewPhotoFlipCardView
PhotoFlipCardView
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
Everything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View ControllersEverything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View Controllers
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
 
December 2014 University iOS Meetup Talk
December 2014 University iOS Meetup TalkDecember 2014 University iOS Meetup Talk
December 2014 University iOS Meetup Talk
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
iOS 7 Blur Views
iOS 7 Blur ViewsiOS 7 Blur Views
iOS 7 Blur Views
 
занятие6
занятие6занятие6
занятие6
 
iOSインタラクションデザイン
iOSインタラクションデザインiOSインタラクションデザイン
iOSインタラクションデザイン
 
I os 03
I os 03I os 03
I os 03
 
아이폰강의(5) pdf
아이폰강의(5) pdf아이폰강의(5) pdf
아이폰강의(5) pdf
 
Heat on Wed.(ヒートオンウェンズディ)! Vol.1
Heat on Wed.(ヒートオンウェンズディ)! Vol.1Heat on Wed.(ヒートオンウェンズディ)! Vol.1
Heat on Wed.(ヒートオンウェンズディ)! Vol.1
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Utilising View Controllers