UIAlertView, UIActionSheet, and Facebook Connection Lecture 4 1.
-
date post
19-Dec-2015 -
Category
Documents
-
view
216 -
download
0
Transcript of UIAlertView, UIActionSheet, and Facebook Connection Lecture 4 1.
UIAlertView, UIActionSheet, and Facebook Connection
Lecture 4
1
Organization
2
Part 2 – Two Common Controls and Delegate Concept 2.1 UIAlertView 2.2 UIActionSheet
Part 3 – Facebook Connection 3.1 Facebook Role 3.2 iPhone Role
UIAlertView - Introduction
3
A UI component that pops up to catch user immediate attention and respond for some internal status changes In Tutorial 3 Part 3.3, the following screen is
shown when game ends
UIAlertView
UIAlertView - Introduction II
4
Note that you must respond by clicking the button before you can do any other action on the screen view. For example, Situation 1: You can try shaking the device when
the UIAlertView is shown up. Situation 2: You can try shaking the device after
you have pressed the button.
Analogy: Windows Alert
5
Windows also has similar function. For example: When I turn off the system without saving this
powerpoint file, the following alert is popped up:
UIAlertView – Multiple Choices
6
Other than catching the user attention, another useful function is to provide choices for the user.
Recall that to activate the UIAlertView:
UIAlertView – Multiple Choices II
7
Note that the “otherButtonTitles” field is nil To provide more buttons in the UIAlertView,
we can put in other string value(s) as parameter(s) of the “otherButtonTitles” field
UIAlertView – Multiple Choices III
8
Now, we know how to create a UIAlertView with two or more buttons.
Quick Questions: How do we know
that which button is clicked if there are multiple buttons?
Delegate Concept
Delegate – Basic Concept
9
When certain events (e.g., press a button in a UIAlertView) occur on a certain kind of UI components (e.g., UIAlertView), the components will call back its delegate to handle the event for it.VolcanoRockEscapingViewController1.
Register as delegate
VolcanoRockEscapingViewController2.
Call back(Please handle this event for me)
Delegate - Requirements
10
Now, we know the role of a delegate. However, to become a “valid” delegate, there are some requirements:
1. The UI component can detect some events on it and allow its delegate to handle it
2. The object has to intentionally register as the delegate of the UI component.
3. The object has to declare and implement the functions to handle the event
Delegate – Registration
11
When did “VolcanoRockEscapingView Controller” register as delegate of the UIAlertView?
Delegate – How to handle the event?
12
How can “VolcanoRockEscapingViewController” handle the event? For some UI components, the SDK has provided a
predefined set of handler function declaration. The delegate can handle the event by implementing
the predefined set of functions
To handle the UIAlertView event, we have to:1. Declare in
“VolcanoRockEscapingViewController.h”that it has implement the function
2. Implement the related function in the “VolcanoRockEscapingViewController.m”
Codes Modification Required
13
In “VolcanoRockEscapingViewController.h” file, we need to declare that this class has implement the function
In “VolcanoRockEscapingViewController.m” file, we need to implement the following function:
UIActionSheet - Introduction
14
Similar to that of UIAlertView, it is used to catch the user’s attention, and provide selection choices to users.
UIActionSheet
UIActionSheet – Introduction II
15
Unlike that of UIAlertView UIActionSheet object slides up from bottom, while
UIAlertView object is popped up in the center. UIActionSheet object is more likely to be activated by
user, while UIAlertView is more likely to be activated by the change of internal status.
UIActionSheet object is mainly used to provide more choices for the user, while UIAlertView is mainly used to inform the user about the status changes
Please refer to the tutorial sheet for the objective-C codes on activation, detection of button clicked, etc. (Very similar to that of UIAlertView )
Facebook Connection - Introduction I
16
Facebook has provided an open source iPhone Facebook Development Kit for iPhone developers to connect to the user’s facebook account.
Basically, the relationship between iPhone programming and facebook can be summarized as follows:Your
iPhone App
iPhone Facebook SDK
Facebook App
Facebook User
Account
Facebook RoleiPhone Role
Facebook Connection - Introduction II
17
iPhone app makes use of the iPhone Facebook Development Kit to connect to a facebook app.
The facebook app can then act on behalf of the iPhone app to access the user’s facebook account information.
The information accessed includes, post feeds, user’s friends information, etc.
Procedures in Making Facebook Connection
18
3.1 Setup a facebook developer account and a facebook app
3.2 Setup the iPhone facebook SDK
3.3 Login facebook through iPhone
3.4 Upload photo with a message
Please refer back to the tutorial sheet for the detail descriptions
Challenges (Optional)
19
1. Different styles of VolcanoRock generation pattern
2. Different difficulty levels3. Keeping best score4. Any others?