iOS development Crash course in how to build an native application for iPhone.
i will be start from beginning till publishing on Apple Store step by step.
this session # 4
3. Previous session we have built an app
that showed a few important different
areas of Xcode including your first look
at storyboards and the Assistant Editor in
addition to understanding where the
entry point for an application is
4. Outlet and IBAction•Outlets are the bridge between Interface Builder
and code.
• Each control you place in IB can be
represented by an outlet in your Code files.
• An outlet reference can be used to modify the
look of these controls and update the data they
present.
•To add an outlet, we need to use the Assistant
Editor in Xcode, then hold Ctrl while dragging a
connection line from the control in IB to the
source code file where we want to create the
7. LayersUp to this point, we’ve been dealing with views, and views only.
In reality, most view classes in UIKit do not expose properties that
you come to expect when designing user interfaces.
Corner radiuses and borders are two notable examples. This is
where layers (represented by the CALayer main class) come into
play.
Put simply, every view in iOS is backed by a layer object that is
responsible for drawing what you see on the screen and managing
its geometry (origin, position, rotation, etc).
Several methods and properties on UIView subclasses act as a thin
wrapper over their layer counterparts.
While a view can have only one backing layer (or root layer), you
can insert any number of sublayers into its layer stack, effectively
creating a layer hierarchy, where layers are nested within other
8. Navigation Controller
A Navigation Controller is a very common
navigation technique in iOS development.
This is very useful when you have a
hierarchy of views where you might tap
something in one view and descend into
another view where you want to have a back
button to return to the first.
In this instance, you’d have a back button at
the top left of the navigation bar on the
second view.
9. Navigation Controller
select the view (click anywhere in the
whitespace of the view)
and go to the Editor menu and
choose Embed In –> Navigation
Controller.
12. loading View
Create A view
UIActivityIndicatorVie
w
Hide and show from
Buttons Action
13. progress bar
Download Library from
https://github.com/jdg/MBProgressH
UD
2)Copy the MBProgressHUD.h and
MBProgressHUD.m file into your
project.
14. progress barHow to use MBProgressHUD
MBProgressHUD is very popular and well designed
circular activity indicator library for developing
IphoneApplications.
MBProgressHUD is very flexible and well functioned
ProgressView library.
MBProgressHUD is simple general library could
integrate by new developers.Its not that much hard
enough.
MBProgressHUD does not need to install Cocoa
Pods,You can directly drag and drop class files in your
project.
15. UIWebView (
WebView )
How to add UIWebView to a View
Load Request/Data in UIWebView
UIWebViewDelegate methods
Execute Javascript in UIWebView
Create UIWebView programmatically
17. How to Add
UIWebView to A view
Drag and drop UIWebView Widget from
Object Library to storyboard.
Add an IBOutlet to view controller and
link it to WebView
@interface ViewController :
UIViewController{
}
@property (weak, nonatomic) IBOutlet
UIWebView *webview;
@end
18. LOADING REQUEST
IN WEBVIEW
requestWithURL is used to load a URL in Webview
NSURL *url = [NSURL
URLWithString:“http://www.google.com”];
NSURLRequest *request = [NSURLRequest
requestWithURL:url];
[WebView loadRequest:request];
http://stackoverflow.com/questions/30731785/how-do-i-
load-an-http-url-with-app-transport-security-enabled-in-
ios-9
19. App Transport Security policy requires
Because App Transport Security policy
requires the use of a secure connection, or
unless you whitelist it.
Add the following to your Info.plst:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
20. NSString * string =
@“<html><body><h1> hi its me
again </h1>How to <a href="/add-
custom-fonts-ios/">Add Custom
Font</a>”;
[webView loadHTMLString:string
baseURL:[NSURL
URLWithString:@"http://google.com"]
];
21. NSString * path =[[NSBundle mainBundle]
pathForResource:@"Resume"
ofType:@“doc”];
NSData *data =[[NSFileManager
defaultManager] contentsAtPath:path];
[webView loadData:data
MIMEType:@"application/msword"
textEncodingName:@"UTF-8"
baseURL:nil];
To get the list of MIME
types:http://webdesign.about.com/od/multi
22. Delegate
Let's assume an object A calls an object B to perform an
action.
Once the action is complete, object A should know that
B has completed the task and take necessary action.
This is achieved with the help of delegates.
The key concepts in the above example are −
1.A is a delegate object of B.
2.B will have a reference of A.
3.A will implement the delegate methods of B.
4.B will notify A through the delegate methods.
24. UIWebViewDelegate has the following
delegate methods.
1.webView:shouldStartLoadWithRequest:na
vigationType
2.webViewDidStartLoad
3.webViewDidFinishLoad
4.webView:didFailLoadWithError
https://developer.apple.com/reference/uikit/u
iwebviewdelegate
29. webView:didFailLoad
WithError
method is called if frame loading is
failed.
- (void)webView:(UIWebView *)webView
didFailLoadWithError:(NSError *)error
{
NSLog(@"Failed to load with error :%@",[error
debugDescription]);
}
30. Assignment
1-Create a Browser Application that have the
following
1- Can Go back
2- Can GO Forward
3- Have Loading bar while requesting string
4- User can write any url to surf the internet
31. THANKS
▸Skype : amr_elghadban
▸Email : amr.elghadban@gmail.com
▸Phone : (+20) 1098558500
▸Fb/amr.elghadban
▸Linkedin/amr_elghadban
▸ios_course facebook group :
https://www.facebook.com/groups/1161387897317786/
WISH YOU WONDERFUL DAY