1. Trang chủ
  2. » Công Nghệ Thông Tin

iOS notes for professionals

893 633 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 893
Dung lượng 14,18 MB

Nội dung

iOS Developer iOS Developer Notes for Professionals ® Notes for Professionals 800+ pages of professional hints and tricks GoalKicker.com Free Programming Books Disclaimer This is an unocial free book created for educational purposes and is not aliated with ocial iOS® Developer group(s) or company(s) All trademarks and registered trademarks are the property of their respective owners Contents About Chapter 1: Getting started with iOS Development Section 1.1: Creating a default Single View Application Section 1.2: Hello World Section 1.3: Xcode Interface 11 Section 1.4: Create your first program in Swift 17 Chapter 2: UILabel 22 Section 2.1: Create a UILabel 22 Section 2.2: Number of Lines 24 Section 2.3: Set Font 25 Section 2.4: Text Color 26 Section 2.5: Background Color 27 Section 2.6: Size to fit 27 Section 2.7: Text alignment 30 Section 2.8: Calculate Content Bounds (for i.e dynamic cell heights) 30 Section 2.9: Label Attributed Text 32 Section 2.10: Clickable Label 38 Section 2.11: Variable height using constraints 39 Section 2.12: LineBreakMode 39 Section 2.13: Add shadows to text 41 Section 2.14: Changing Text in an Existing Label 41 Section 2.15: Auto-size label to fit text 42 Section 2.16: Get UILabel's size strictly based on its text and font 43 Section 2.17: Highlighted and Highlighted Text Color 44 Section 2.18: Justify Text 44 Section 2.19: Dynamic label frame from unknown text length 45 Chapter 3: UILabel text underlining 47 Section 3.1: Underlining a text in a UILabel using Objective C 47 Section 3.2: Underlining a text in UILabel using Swift 47 Chapter 4: attributedText in UILabel 48 Section 4.1: HTML text in UILabel 48 Section 4.2: Set dierent property to text in single UILabel 48 Chapter 5: UIButton 50 Section 5.1: Creating a UIButton 50 Section 5.2: Attaching a Method to a Button 50 Section 5.3: Setting Font 51 Section 5.4: Set Image 51 Section 5.5: Get UIButton's size strictly based on its text and font 51 Section 5.6: Disabling a UIButton 52 Section 5.7: Set title 52 Section 5.8: Set title color 52 Section 5.9: Horizontally aligning contents 53 Section 5.10: Getting the title label 53 Section 5.11: Adding an action to an UIButton via Code (programmatically) 54 Chapter 6: UIDatePicker 55 Section 6.1: Create a Date Picker 55 Section 6.2: Setting Minimum-Maximum Date 55 Section 6.3: Modes 55 Section 6.4: Setting minute interval 55 Section 6.5: Count Down Duration 56 Chapter 7: UILocalNotification 57 Section 7.1: Scheduling a local notification 57 Section 7.2: Presenting a local notification immediately 57 Section 7.3: Managing local notifications using UUID 58 Section 7.4: Registering for local notifications 59 Section 7.5: what's new in UILocalNotification with iOS10 60 Section 7.6: Responding to received local notification 62 Section 7.7: Register and Schedule Local Notification in Swift 3.0 (iOS 10) 62 Chapter 8: UIImage 64 Section 8.1: Creating UIImage 64 Section 8.2: Comparing Images 65 Section 8.3: Gradient Image with Colors 66 Section 8.4: Convert UIImage to/from base64 encoding 66 Section 8.5: Take a Snapshot of a UIView 67 Section 8.6: Change UIImage Color 67 Section 8.7: Apply UIColor to UIImage 67 Section 8.8: Creating and Initializing Image Objects with file contents 68 Section 8.9: Resizable image with caps 68 Section 8.10: Gradient Background Layer for Bounds 69 Chapter 9: Convert NSAttributedString to UIImage 70 Section 9.1: NSAttributedString to UIImage Conversion 70 Chapter 10: UIImagePickerController 71 Section 10.1: Generic usage of UIImagePickerController 71 Chapter 11: UIImageView 73 Section 11.1: UIImage masked with Label 73 Section 11.2: Making an image into a circle or rounded 73 Section 11.3: How the Mode property aects an image 74 Section 11.4: Animating a UIImageView 80 Section 11.5: Create a UIImageView 81 Section 11.6: Change color of an image 82 Section 11.7: Assigning an image to a UIImageView 82 Chapter 12: Resizing UIImage 83 Section 12.1: Resize any image by size & quality 83 Chapter 13: Cut a UIImage into a circle 84 Section 13.1: Cut a image into a circle - Objective C 84 Section 13.2: SWIFT Example 85 Chapter 14: UITableView 87 Section 14.1: Self-Sizing Cells 87 Section 14.2: Custom Cells 87 Section 14.3: Separator Lines 90 Section 14.4: Delegate and Datasource 92 Section 14.5: Creating a UITableView 98 Section 14.6: Swipe to Delete Rows 102 Section 14.7: Expanding & Collapsing UITableViewCells 105 Chapter 15: UITableViewController 108 Section 15.1: TableView with dynamic properties with tableviewCellStyle basic 108 Section 15.2: TableView with Custom Cell 109 Chapter 16: UIRefreshControl TableView 111 Section 16.1: Set up refreshControl on tableView: 111 Section 16.2: Objective-C Example 111 Chapter 17: UITableViewCell 113 Section 17.1: Xib file of UITableViewCell 113 Chapter 18: Custom methods of selection of UITableViewCells 114 Section 18.1: Distinction between single and double selection on row 114 Chapter 19: Custom methods of selection of UITableViewCells 115 Section 19.1: Distinction between single and double selection on row 115 Chapter 20: UIView 116 Section 20.1: Make the view rounded 116 Section 20.2: Using IBInspectable and IBDesignable 118 Section 20.3: Taking a snapshot 121 Section 20.4: Create a UIView 121 Section 20.5: Shake a View 121 Section 20.6: Utilizing Intrinsic Content Size 122 Section 20.7: Programmatically manage UIView insertion and deletion into and from another UIView 124 Section 20.8: Create UIView using Autolayout 125 Section 20.9: Animating a UIView 127 Section 20.10: UIView extension for size and frame attributes 127 Chapter 21: Snapshot of UIView 129 Section 21.1: Getting the Snapshot 129 Section 21.2: Snapshot with subview with other markup and text 129 Chapter 22: UIAlertController 131 Section 22.1: AlertViews with UIAlertController 131 Section 22.2: Action Sheets with UIAlertController 132 Section 22.3: Adding Text Field in UIAlertController like a prompt Box 135 Section 22.4: Highlighting an action button 135 Section 22.5: Displaying and handling alerts 136 Chapter 23: UIColor 141 Section 23.1: Creating a UIColor 141 Section 23.2: Creating a UIColor from hexadecimal number or string 142 Section 23.3: Color with Alpha component 144 Section 23.4: Undocumented Methods 145 Section 23.5: UIColor from an image pattern 146 Section 23.6: Lighter and Darker Shade of a given UIColor 147 Section 23.7: Make user defined attributes apply the CGColor datatype 148 Chapter 24: UITextView 149 Section 24.1: Set attributed text 149 Section 24.2: Change font 149 Section 24.3: Auto Detect Links, Addresses, Dates, and more 149 Section 24.4: Change text 150 Section 24.5: Change text alignment 150 Section 24.6: UITextViewDelegate methods 150 Section 24.7: Change text color 151 Section 24.8: Remove extra paddings to fit to a precisely measured text 151 Section 24.9: Getting and Setting the Cursor Postition 151 Section 24.10: UITextView with HTML text 153 Section 24.11: Check to see if empty or nil 153 Chapter 25: UITextField Delegate 154 Section 25.1: Actions when a user has started/ended interacting with a textfield 154 Section 25.2: UITextField - Restrict textfield to certain characters 155 Chapter 26: UINavigationController 156 Section 26.1: Embed a view controller in a navigation controller programmatically 156 Section 26.2: Popping in a Navigation Controller 156 Section 26.3: Purpose 156 Section 26.4: Pushing a view controller onto the navigation stack 157 Section 26.5: Creating a NavigationController 157 Chapter 27: UIGestureRecognizer 158 Section 27.1: UITapGestureRecognizer 158 Section 27.2: UITapGestureRecognizer (Double Tap) 159 Section 27.3: Adding a Gesture recognizer in the Interface Builder 159 Section 27.4: UILongPressGestureRecognizer 160 Section 27.5: UISwipeGestureRecognizer 161 Section 27.6: UIPinchGestureRecognizer 162 Section 27.7: UIRotationGestureRecognizer 163 Chapter 28: UIBarButtonItem 164 Section 28.1: Creating a UIBarButtonItem in the Interface Builder 164 Section 28.2: Creating a UIBarButtonItem 167 Section 28.3: Bar Button Item Original Image with no Tint Color 167 Chapter 29: UIScrollView 168 Section 29.1: Scrolling content with Auto Layout enabled 168 Section 29.2: Create a UIScrollView 171 Section 29.3: ScrollView with AutoLayout 171 Section 29.4: Detecting when UIScrollView finished scrolling with delegate methods 176 Section 29.5: Enable/Disable Scrolling 176 Section 29.6: Zoom In/Out UIImageView 177 Section 29.7: Scroll View Content Size 178 Section 29.8: Restrict scrolling direction 178 Chapter 30: UIStackView 179 Section 30.1: Center Buttons with UIStackview 179 Section 30.2: Create a horizontal stack view programmatically 183 Section 30.3: Create a vertical stack view programmatically 184 Chapter 31: Dynamically updating a UIStackView 185 Section 31.1: Connect the UISwitch to an action we can animate switching between a horizontal or vertical layout of the image views 185 Chapter 32: UIScrollView with StackView child 186 Section 32.1: A complex StackView inside Scrollview Example 186 Section 32.2: Preventing ambiguous layout 187 Section 32.3: Scrolling to content inside nested StackViews 188 Chapter 33: UIScrollView AutoLayout 189 Section 33.1: ScrollableController 189 Section 33.2: UIScrollView dynamic content size through Storyboard 193 Chapter 34: UITextField 195 Section 34.1: Get Keyboard Focus and Hide Keyboard 195 Section 34.2: Dismiss keyboard when user pushes the return button 195 Section 34.3: Hide blinking caret 196 Section 34.4: Input accessory view (toolbar) 196 Section 34.5: Moving scroll when UITextView becomes first responder 197 Section 34.6: KeyboardType 199 Section 34.7: Change placeholder color and font 199 Section 34.8: Replace keyboard with UIPickerView 200 Section 34.9: Create a UITextField 203 Section 34.10: Getting and Setting the Cursor Position 204 Section 34.11: Dismiss Keyboard 205 Section 34.12: Initialize text field 208 Section 34.13: Autocapitalization 208 Section 34.14: Set Alignment 209 Chapter 35: Custom UITextField 210 Section 35.1: Custom UITextField for Filtering Input Text 210 Section 35.2: Custom UITextField to Disallow All Actions like Copy, Paste, etc 210 Chapter 36: UIViewController 212 Section 36.1: Subclassing 212 Section 36.2: Access the container view controller 214 Section 36.3: Set the view programmatically 214 Section 36.4: Instantiate from a Storyboard 214 Section 36.5: Create an instance 215 Section 36.6: Adding/removing a child view controller 216 Chapter 37: UISwitch 217 Section 37.1: Set Image for On/O state 217 Section 37.2: Set On / O 217 Section 37.3: Set Background Color 217 Section 37.4: Set Tint Color 218 Chapter 38: UICollectionView 219 Section 38.1: Create a UICollectionView 219 Section 38.2: UICollectionView - Datasource 219 Section 38.3: Basic Swift example of a Collection View 220 Section 38.4: Manage Multiple Collection view with DataSource and Flowlayout 225 Section 38.5: UICollectionViewDelegate setup and item selection 227 Section 38.6: Create a Collection View Programmatically 228 Section 38.7: Swift - UICollectionViewDelegateFlowLayout 229 Section 38.8: Performing batch updates 229 Chapter 39: UISearchController 231 Section 39.1: Search Bar in Navigation Bar Title 231 Section 39.2: Search Bar in Table View Header 234 Section 39.3: Implementation 237 Section 39.4: UISerachController in Objective-C 237 Chapter 40: UITabBarController 239 Section 40.1: Create an instance 239 Section 40.2: Navigation Controller with TabBar 239 Section 40.3: Tab Bar color customizing 240 Section 40.4: Changing Tab Bar Item Title and Icon 240 Section 40.5: Create Tab Bar controller programmatically without Storyboard 241 Section 40.6: UITabBarController with custom color selection 242 Chapter 41: UIWebView 245 Section 41.1: Create a UIWebView instance 245 Section 41.2: Determining content size 245 Section 41.3: Load HTML string 245 Section 41.4: Making a URL request 246 Section 41.5: Load JavaScript 246 Section 41.6: Stop Loading Web Content 247 Section 41.7: Reload Current Web Content 247 Section 41.8: Load Document files like pdf, txt, doc etc 247 Section 41.9: Load local HTML file in webView 247 Section 41.10: Make links That inside UIWebview clickable 248 Chapter 42: UIActivityViewController 250 Section 42.1: Initializing the Activity View Controller 250 Chapter 43: UIControl - Event Handling with Blocks 251 Section 43.1: Introduction 251 Chapter 44: UISplitViewController 254 Section 44.1: Master and Detail View interaction using Delegates in Objective C 254 Chapter 45: UISlider 264 Section 45.1: UISlider 264 Section 45.2: SWIFT Example 264 Section 45.3: Adding a custom thumb image 264 Chapter 46: UIStoryboard 266 Section 46.1: Getting an instance of UIStoryboard programmatically 266 Section 46.2: Open another storyboard 266 Chapter 47: UIPageViewController 267 Section 47.1: Create a horizontal paging UIPageViewController programmatically 267 Section 47.2: A simple way to create horizontal page view controllers ( infinite pages ) 268 Chapter 48: UISplitViewController 272 Section 48.1: Interacting Between Master and Detail View using Delegates in Objective C 272 Chapter 49: UIFont 276 Section 49.1: Declaring and initializing UIFont 276 Section 49.2: Changing the font of a label 276 Chapter 50: UIDevice 277 Section 50.1: Get iOS device model name 277 Section 50.2: Identifying the Device and Operating 278 Section 50.3: Getting the Device Orientation 279 Section 50.4: Getting the Device Battery State 280 Section 50.5: Using the Proximity Sensor 281 Section 50.6: Getting Battery Status and Battery Level 281 Chapter 51: Make selective UIView corners rounded 282 Section 51.1: Objective C code to make selected corner of a UiView rounded 282 Chapter 52: Custom UIViews from XIB files 283 Section 52.1: Wiring elements 283 Section 52.2: How to make custom reusable UIView using XIB 297 Chapter 53: UIBezierPath 298 Section 53.1: Designing and drawing a Bezier Path 298 Section 53.2: How to apply corner radius to rectangles drawn by UIBezierPath 303 Section 53.3: How to apply shadows to UIBezierPath 305 Section 53.4: How to create a simple shapes using UIBezierPath 307 Section 53.5: UIBezierPath + AutoLayout 309 Section 53.6: pie view & column view with UIBezierPath 310 Chapter 54: UIPickerView 313 Section 54.1: Basic example 313 Section 54.2: Changing pickerView Background Color and text color 314 Chapter 55: UIFeedbackGenerator 315 Section 55.1: Trigger Impact Haptic 315 Chapter 56: UIAppearance 317 Section 56.1: Set appearance of all instances of the class 317 Section 56.2: Appearance for class when contained in container class 318 Chapter 57: UIKit Dynamics with UICollectionView 319 Section 57.1: Creating a Custom Dragging Behavior with UIDynamicAnimator 319 Chapter 58: UIPheonix - easy, flexible, dynamic & highly scalable UI framework 329 Section 58.1: Example UI Components 329 Section 58.2: Example Usage 331 Chapter 59: UIKit Dynamics 332 Section 59.1: Flick View Based on Gesture Velocity 332 Section 59.2: "Sticky Corners" Eect Using UIFieldBehaviors 335 Section 59.3: UIDynamicBehavior Driven Custom Transition 340 Section 59.4: Shade Transition with Real-World Physics Using UIDynamicBehaviors 351 Section 59.5: Map Dynamic Animation Position Changes to Bounds 363 Section 59.6: The Falling Square 368 Chapter 60: UI Testing 370 Section 60.1: Accessibility Identifier 370 Section 60.2: Adding Test Files to Xcode Project 372 Section 60.3: Disable animations during UI Testing 373 Section 60.4: Lunch and Terminate application while executing 373 Section 60.5: Rotate devices 373 Chapter 61: Change Status Bar Color 374 Section 61.1: For non-UINavigationBar status bars 374 Section 61.2: For UINavigationBar status bars 374 Section 61.3: For ViewController containment 375 Section 61.4: If you cannot change ViewController's code 375 Section 61.5: Changing the status bar style for the entire application 375 Chapter 62: UISegmentedControl 377 Section 62.1: Creating UISegmentedControl via code 377 Chapter 63: Passing Data between View Controllers 378 Section 63.1: Using the Delegate Pattern (passing data back) 378 Section 63.2: Using Segues (passing data forward) 380 Section 63.3: Passing data backwards using unwind to segue 381 Section 63.4: Passing data using closures (passing data back) 382 Section 63.5: Using callback closure(block) passing data back 383 Section 63.6: By assigning property (Passing data forward) 384 Chapter 64: Managing the Keyboard 385 Section 64.1: Create a custom in-app keyboard 385 Section 64.2: Dismiss a keyboard with tap on view 389 Section 64.3: Managing the Keyboard Using a Singleton + Delegate 390 Section 64.4: Moving view up or down when keyboard is present 393 Section 64.5: Scrolling a UIScrollView/UITableView When Displaying the Keyboard 394 Chapter 65: Checking for Network Connectivity 396 Section 65.1: Creating a Reachability listener 396 Section 65.2: Add observer to network changes 396 Section 65.3: Alert when network becomes unavailable 396 Section 65.4: Alert when connection becomes a WIFI or cellular network 396 Section 65.5: Verify if is connected to network 397 Chapter 66: Accessibility 399 Section 66.1: Make a View Accessible 399 Section 66.2: Accessibility Frame 399 Section 66.3: Layout Change 399 Section 66.4: Accessibility Container 399 Section 66.5: Hiding Elements 400 Section 66.6: Screen Change 400 Section 66.7: Announcement 400 Section 66.8: Ordering Elements 400 Section 66.9: Modal View 401 Chapter 67: Auto Layout 402 Section 67.1: Space Views Evenly 402 Section 67.2: Center Constraints 403 Section 67.3: Setting constraints programmatically 406 Section 67.4: UILabel & Parentview size According to Text in UILabel 407 Section 67.5: UILabel Intrinsic Size 412 Section 67.6: Visual Format Language Basics: Constraints in Code! 422 Section 67.7: Resolve UILabel Priority Conflict 424 Section 67.8: How to animate with Auto Layout 426 Section 67.9: NSLayoutConstraint: Contraints in code! 427 Section 67.10: Proportional Layout 428 Section 67.11: Mixed usage of Auto Layout with non-Auto Layout 429 Section 67.12: How to use Auto Layout 429 Chapter 68: MKMapView 431 Section 68.1: Change map-type 431 Section 68.2: Simulate a custom location 435 Section 68.3: Set Zoom/Region for Map 435 Section 68.4: Local search implementation using MKLocalSearch 436 Section 68.5: OpenStreetMap Tile-Overlay 436 Section 68.6: Scroll to coordinate and zoom-level 438 Section 68.7: Working With Annotation 440 Section 68.8: Add MKMapView 440 Section 68.9: Show UserLocation and UserTracking example 441 Section 68.10: Adding Pin/Point Annotation on map 444 Section 68.11: Adjust the map view's visible rect in order to display all annotations 445 Chapter 69: NSArray 446 Section 69.1: Convert Array into json string 446 Chapter 70: NSAttributedString 447 Section 70.1: Creating a string that has custom kerning (letter spacing) 447 Section 70.2: Change the color of a word or string 447 Section 70.3: Removing all attributes 448 Section 70.4: Appending Attributed Strings and bold text in Swift 448 Section 70.5: Create a string with strikethrough text 448 Chapter 71: Convert HTML to NSAttributed string and vice verse 450 Section 71.1: Objective C code to convert HTML string to NSAttributedString and Vice Versa 450 Chapter 72: NSTimer 451 Section 72.1: Creating a Timer 451 Section 72.2: Manually firing a timer 451 Section 72.3: Timer frequency options 452 Section 72.4: Invalidating a timer 453 Section 72.5: Passing of data using Timer 453 Chapter 73: NSDate 454 Section 73.1: NSDateFormatter 454 Section 73.2: Date Comparison 455 Section 73.3: Get Historic Time from NSDate (eg: 5s ago, 2m ago, 3h ago) 457 Section 73.4: Get Unix Epoch time 458 Section 73.5: Get NSDate from JSON Date format "/Date(1268123281843)/" 458 Section 73.6: Get time cycle type (12-hour or 24-hour) 459 Section 73.7: Get Current Date 459 Section 73.8: Get NSDate Object N seconds from current date 459 Section 73.9: UTC Time oset from NSDate with TimeZone 460 Section 73.10: Convert NSDate that is composed from hour and minute (only) to a full NSDate 460 Chapter 74: NSNotificationCenter 462 Section 74.1: Removing Observers 462 Section 74.2: Adding an Observer 462 Section 74.3: Posting a Notification with Data 463 Section 74.4: Add and remove observer for name 463 Section 74.5: Posting a Notification 463 Section 74.6: Observing a Notification 464 Section 74.7: Adding/Removing an Observer with a Block 464 Chapter 75: NSURLSession 465 Section 75.1: Objective-C Create a Session And Data Task 465 Section 75.2: Setting up background configuration 465 Section 75.3: Simple GET request 466 Section 75.4: Sending a POST Request with arguments using NSURLSession in Objective-C 466 Chapter 76: NSUserDefaults 471 Section 76.1: Setting values 471 Section 76.2: UserDefaults uses in Swift 472 Section 76.3: Use Managers to Save and Read Data 473 Section 76.4: Saving Values 475 Section 76.5: Clearing NSUserDefaults 475 Section 76.6: Getting Default Values 475 Chapter 77: NSHTTPCookieStorage 477 Section 77.1: Store and read the cookies from NSUserDefault 477 Chapter 78: NSURLConnection 479 Section 78.1: Delegate methods 479 Section 78.2: Synchronous Request 479 Section 78.3: Asynchronous request 480 Chapter 79: NSURL 481 Section 79.1: How to get last string component from NSURL String 481 Section 79.2: How to get last string component from URL (NSURL) in Swift 481 Chapter 80: NSData 482 ... iOS 8.1 2014-10-20 iOS 8.2 2015-03-09 iOS 8.3 2015-04-08 iOS 8.4 2015-06-30 iOS 2015-09-16 iOS 9.1 2015-10-22 iOS 9.2 2015-12-08 iOS 9.3 2016-03-21 iOS 10.0.1 2016-09-13 iOS 10.1 2016-10-24 iOS. .. Notes for Professionals Chapter 1: Getting started with iOS Development Version Release Date iPhone OS 2008-07-11 iPhone OS 2009-06-17 iOS 2010-06-08 iOS 2011-10-12 iOS 2012-09-19 iOS 2013-09-18 iOS. .. free to share this PDF with anyone for free, latest version of this book can be downloaded from: https://goalkicker.com/iOSBook This iOS Developer Notes for Professionals book is compiled from

Ngày đăng: 21/04/2019, 14:48

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN