SlideShare a Scribd company logo
1 of 45
Building User Interfaces
                    for iPhone Applications 101

                            John Kennedy - February 2009




Friday, February 20, 2009
Your tools: Xcode and Interface
                   Builder, and the Cocoa Touch framework.

Friday, February 20, 2009
Xcode: the IDE that includes source code
                            editor, tools, documentation and the front
                            end for the compiler i.e. with Xcode you can
                            enter, build and debug your application.

                            Interface Builder: an editor program for
                            dragging controls into your application’s
                            views and editing them visually.

                            Cocoa Touch: a framework of code for you to
                            use. Cocoa Touch contains controls and other
                            useful stuff for your iPhone applications.




Friday, February 20, 2009
The Cocoa Touch framework provides a
                            code library called UIKit for
                            creating iPhone-friendly controls.

                            Controls can be created
                            programmatically, but..

                            The Interface Builder tool makes
                            almost all of the process ‘drag and
                            drop’, and is the recommended
                            approach whenever possible.


Friday, February 20, 2009
UIViewController is the UIKit class
                            that provides the most fundamental
                            support for all iPhone ‘views’.

                            UIViewController, or its subclasses,
                            can manage (amongst others) tab bars,
                            navigation controls, and will even
                            rotate the display for you
                            automatically.




Friday, February 20, 2009
You could create your controls in your
                            UIViewController subclass
                            programmatically, by implementing the
                            loadView method.

                            Or you could use Interface Builder to
                            create a NIB file that contains all the
                            details of your view’s controls.

                            That’s all a NIB file is: a way of
                            storing a user interface. We’ll do it
                            that way.


Friday, February 20, 2009
When you consider how your application works,
                   it will probably have multiple views: for
                   example; one that displays groups, and one
                   that displays a list of names.
Friday, February 20, 2009
When you consider how your application works,
                   it will probably have multiple views: for
                   example; one that displays groups, and one
                   that displays a list of names.
Friday, February 20, 2009
Remember that each view is a class,
                            and so contains all the code that is
                            required to do what it needs to do:
                            for example, the class might contain
                            code that creates a list of names and
                            let the user select one.

                            Your application works by switching
                            between these different views.




Friday, February 20, 2009
How you switch between these views is
                            up to you, and the design of your
                            application.

                            It is important to spend time in
                            advance thinking about how your user
                            will switch between views.




Friday, February 20, 2009
Sketch your design out on paper
                            first, to make sure the ‘flow’ makes
                            sense.

                            Think about dividing information
                            between views. Will all your settings
                            be in one view? How many views are
                            needed?




Friday, February 20, 2009
Sketch your design out on paper
                            first, to make sure the ‘flow’ makes
                            sense.

                            Think about dividing information
                            between views. Will all your settings
                            be in one view? How many views are
                            needed?




Friday, February 20, 2009
A Tab Bar control is one way the user
                   could switch between your
                   application’s views.


Friday, February 20, 2009
A Tab Bar control is one way the user
                   could switch between your
                   application’s views.


Friday, February 20, 2009
Other common design patterns include
                   ‘drilling down’ from one view to
                   another.

Friday, February 20, 2009
Other common design patterns include
                   ‘drilling down’ from one view to
                   another.

Friday, February 20, 2009
The UINavigationController handles
                            this type of display for you, by
                            maintaining a stack of views and
                            providing navigation.




Friday, February 20, 2009
So what does each view look like,
                            from the point of view of you, the
                            programmer?

                            Each views will be encapsulated in
                            separate ‘chunks’ within your
                            application.




Friday, February 20, 2009
Here’s what each view involves:




Friday, February 20, 2009
Here’s what each view involves:

                                 Created with Interface Builder, the NIB file
                        NIB
      1.                         contains the controls, buttons, and other elements
                       File      that you have visually designed.

                                 A class (comprised of a .m file, and a .h file)
                            .m
      2.                         which is a subclass of UIViewController. Xcode will
                            .h   quickly help you create these source files.


                                                             Class




                                                              NIB



Friday, February 20, 2009
The important part!



                             NIB               .m
                            File               .h




                   You must introduce the NIB to the code
                   so they know about each other.

Friday, February 20, 2009
The important part!



                             NIB               .m
                            File               .h




                   You must introduce the NIB to the code
                   so they know about each other.

Friday, February 20, 2009
Here’s a step-by-step guide to how you
                            create a new view (both source code and
                            NIB) and wire them together.. watch
                            closely.. there is nothing up my sleeve..




Friday, February 20, 2009
1.0 Creating the source code.




            Select ‘Classes’ and Add -> New File...

Friday, February 20, 2009
1.1 Creating the source code.




                      Select UIViewController Class from
                              Cocoa Touch Classes
Friday, February 20, 2009
1.2 Creating the source code.




              Give it a name. I like to use the form
               XXXViewController. You don’t have to.
Friday, February 20, 2009
1.3 Creating the source code.




              There you go: your .h and you .m file,
            describing a subclass of UIViewController.
Friday, February 20, 2009
2.0 Create the NIB file part.




            This time select Resources as the folder, and
                          Add -> New File.
Friday, February 20, 2009
2.1 Create the NIB file part.




                             Use a View.XIB template.
                (Note: XIB is the new, improved version of NIB. We just keep
             calling them NIB files for old time’s sake and to confuse noobs.)
Friday, February 20, 2009
2.2 Create the NIB file part.




              Pick a name that will remind you which
            UIViewController class is associated with.
Friday, February 20, 2009
2.3 Create the NIB file part.




    Enjoy your new NIB file as it opens in Interface Builder.
     The blank View panel is where you can drag and drop controls.

Friday, February 20, 2009
2.4 Create the NIB file part.




              Drag some controls onto your View from
                           the Library.
Friday, February 20, 2009
3.0 Connect the NIB to the Class.




             Select File’s Owner, and make sure its class is set
               to be the ViewController class you just created.

Friday, February 20, 2009
3.1 Connect the NIB to the Class.




                    Connect the View to File’s Owner.
            (Option-Click on Files’s Owner and drag to View)
Friday, February 20, 2009
And that’s that.




Friday, February 20, 2009
But how do you make the views, you
                            know, actually visible?




Friday, February 20, 2009
When your application launches, the
                            default view (MainWindow.xib) will be
                            displayed.




Friday, February 20, 2009
When your application launches, the
                            default view (MainWindow.xib) will be
                            displayed.




                                       This is the easiest way,
                                      and it means you can write
                                           a simple one-view
                                        application in about 60
                                                seconds!



Friday, February 20, 2009
Other controls (such as Tab Bar
                            controls) can link to the NIB files,
                            thus causing them to appear.




Friday, February 20, 2009
Other controls (such as Tab Bar
                            controls) can link to the NIB files,
                            thus causing them to appear.




                       This isn’t that
                      hard either: you
                   just need to remember
                       to wire them up
                        properly from
                     Interface Builder.


Friday, February 20, 2009
You can create them programmatically
                            from within your application.




Friday, February 20, 2009
You can create them programmatically
                            from within your application.




                                        It turns out that only
                                         takes a few lines of
                                      Objective-C to open a View
                                        from a NIB and make it
                                               visible!



Friday, February 20, 2009
For example, this code creates a new
                      view and uses a Navigation Controller
                      to make it slide smoothly onto the
                      screen.



Friday, February 20, 2009
See? It’s not as scary as you might
                            think to create views and display them.

                            For more information, there are several
                            good 3rd party books including my
                            favourite “iPhone SDK Development” from
                            Pragmatic Programmers.

                            Don’t forget: Apple has some
                            surprisingly good documentation on its
                            iPhone Developer site.



Friday, February 20, 2009
The End

                            Please let me know of errors and
                            omissions: john_kenn@mac.com




Friday, February 20, 2009

More Related Content

Recently uploaded

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 

Recently uploaded (20)

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Building User Interfaces For iPhones 101

  • 1. Building User Interfaces for iPhone Applications 101 John Kennedy - February 2009 Friday, February 20, 2009
  • 2. Your tools: Xcode and Interface Builder, and the Cocoa Touch framework. Friday, February 20, 2009
  • 3. Xcode: the IDE that includes source code editor, tools, documentation and the front end for the compiler i.e. with Xcode you can enter, build and debug your application. Interface Builder: an editor program for dragging controls into your application’s views and editing them visually. Cocoa Touch: a framework of code for you to use. Cocoa Touch contains controls and other useful stuff for your iPhone applications. Friday, February 20, 2009
  • 4. The Cocoa Touch framework provides a code library called UIKit for creating iPhone-friendly controls. Controls can be created programmatically, but.. The Interface Builder tool makes almost all of the process ‘drag and drop’, and is the recommended approach whenever possible. Friday, February 20, 2009
  • 5. UIViewController is the UIKit class that provides the most fundamental support for all iPhone ‘views’. UIViewController, or its subclasses, can manage (amongst others) tab bars, navigation controls, and will even rotate the display for you automatically. Friday, February 20, 2009
  • 6. You could create your controls in your UIViewController subclass programmatically, by implementing the loadView method. Or you could use Interface Builder to create a NIB file that contains all the details of your view’s controls. That’s all a NIB file is: a way of storing a user interface. We’ll do it that way. Friday, February 20, 2009
  • 7. When you consider how your application works, it will probably have multiple views: for example; one that displays groups, and one that displays a list of names. Friday, February 20, 2009
  • 8. When you consider how your application works, it will probably have multiple views: for example; one that displays groups, and one that displays a list of names. Friday, February 20, 2009
  • 9. Remember that each view is a class, and so contains all the code that is required to do what it needs to do: for example, the class might contain code that creates a list of names and let the user select one. Your application works by switching between these different views. Friday, February 20, 2009
  • 10. How you switch between these views is up to you, and the design of your application. It is important to spend time in advance thinking about how your user will switch between views. Friday, February 20, 2009
  • 11. Sketch your design out on paper first, to make sure the ‘flow’ makes sense. Think about dividing information between views. Will all your settings be in one view? How many views are needed? Friday, February 20, 2009
  • 12. Sketch your design out on paper first, to make sure the ‘flow’ makes sense. Think about dividing information between views. Will all your settings be in one view? How many views are needed? Friday, February 20, 2009
  • 13. A Tab Bar control is one way the user could switch between your application’s views. Friday, February 20, 2009
  • 14. A Tab Bar control is one way the user could switch between your application’s views. Friday, February 20, 2009
  • 15. Other common design patterns include ‘drilling down’ from one view to another. Friday, February 20, 2009
  • 16. Other common design patterns include ‘drilling down’ from one view to another. Friday, February 20, 2009
  • 17. The UINavigationController handles this type of display for you, by maintaining a stack of views and providing navigation. Friday, February 20, 2009
  • 18. So what does each view look like, from the point of view of you, the programmer? Each views will be encapsulated in separate ‘chunks’ within your application. Friday, February 20, 2009
  • 19. Here’s what each view involves: Friday, February 20, 2009
  • 20. Here’s what each view involves: Created with Interface Builder, the NIB file NIB 1. contains the controls, buttons, and other elements File that you have visually designed. A class (comprised of a .m file, and a .h file) .m 2. which is a subclass of UIViewController. Xcode will .h quickly help you create these source files. Class NIB Friday, February 20, 2009
  • 21. The important part! NIB .m File .h You must introduce the NIB to the code so they know about each other. Friday, February 20, 2009
  • 22. The important part! NIB .m File .h You must introduce the NIB to the code so they know about each other. Friday, February 20, 2009
  • 23. Here’s a step-by-step guide to how you create a new view (both source code and NIB) and wire them together.. watch closely.. there is nothing up my sleeve.. Friday, February 20, 2009
  • 24. 1.0 Creating the source code. Select ‘Classes’ and Add -> New File... Friday, February 20, 2009
  • 25. 1.1 Creating the source code. Select UIViewController Class from Cocoa Touch Classes Friday, February 20, 2009
  • 26. 1.2 Creating the source code. Give it a name. I like to use the form XXXViewController. You don’t have to. Friday, February 20, 2009
  • 27. 1.3 Creating the source code. There you go: your .h and you .m file, describing a subclass of UIViewController. Friday, February 20, 2009
  • 28. 2.0 Create the NIB file part. This time select Resources as the folder, and Add -> New File. Friday, February 20, 2009
  • 29. 2.1 Create the NIB file part. Use a View.XIB template. (Note: XIB is the new, improved version of NIB. We just keep calling them NIB files for old time’s sake and to confuse noobs.) Friday, February 20, 2009
  • 30. 2.2 Create the NIB file part. Pick a name that will remind you which UIViewController class is associated with. Friday, February 20, 2009
  • 31. 2.3 Create the NIB file part. Enjoy your new NIB file as it opens in Interface Builder. The blank View panel is where you can drag and drop controls. Friday, February 20, 2009
  • 32. 2.4 Create the NIB file part. Drag some controls onto your View from the Library. Friday, February 20, 2009
  • 33. 3.0 Connect the NIB to the Class. Select File’s Owner, and make sure its class is set to be the ViewController class you just created. Friday, February 20, 2009
  • 34. 3.1 Connect the NIB to the Class. Connect the View to File’s Owner. (Option-Click on Files’s Owner and drag to View) Friday, February 20, 2009
  • 35. And that’s that. Friday, February 20, 2009
  • 36. But how do you make the views, you know, actually visible? Friday, February 20, 2009
  • 37. When your application launches, the default view (MainWindow.xib) will be displayed. Friday, February 20, 2009
  • 38. When your application launches, the default view (MainWindow.xib) will be displayed. This is the easiest way, and it means you can write a simple one-view application in about 60 seconds! Friday, February 20, 2009
  • 39. Other controls (such as Tab Bar controls) can link to the NIB files, thus causing them to appear. Friday, February 20, 2009
  • 40. Other controls (such as Tab Bar controls) can link to the NIB files, thus causing them to appear. This isn’t that hard either: you just need to remember to wire them up properly from Interface Builder. Friday, February 20, 2009
  • 41. You can create them programmatically from within your application. Friday, February 20, 2009
  • 42. You can create them programmatically from within your application. It turns out that only takes a few lines of Objective-C to open a View from a NIB and make it visible! Friday, February 20, 2009
  • 43. For example, this code creates a new view and uses a Navigation Controller to make it slide smoothly onto the screen. Friday, February 20, 2009
  • 44. See? It’s not as scary as you might think to create views and display them. For more information, there are several good 3rd party books including my favourite “iPhone SDK Development” from Pragmatic Programmers. Don’t forget: Apple has some surprisingly good documentation on its iPhone Developer site. Friday, February 20, 2009
  • 45. The End Please let me know of errors and omissions: john_kenn@mac.com Friday, February 20, 2009

Editor's Notes