Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 공략
- 포켓몬 GO
- Xcode
- Check
- 페이백
- 샘플
- GCD
- setting
- 해몽
- 얻는법
- 앱스토어
- simulator
- UITableView
- 신도림
- LG유플러스
- 신도림 테크노마트
- swift3
- push
- 보라카이
- error
- IOS
- UIView
- Example
- 스마트폰
- swift
- 포켓볼
- Bitcode
- afterdelay
- 아이폰7
- loop
Archives
- Today
- Total
도래울
swift ActionSheet 예제 본문
Open the Assistant Editor and make sure the ViewController.swift file is visible. Ctrl + drag from the Button to the ViewController class and create the following Action
implement the showActionSheet method
@IBAction func showActionSheet(sender: AnyObject) { // 1 let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .ActionSheet) // 2 let deleteAction = UIAlertAction(title: "Delete", style: .Default, handler: { (alert: UIAlertAction!) -> Void in println("File Deleted") }) let saveAction = UIAlertAction(title: "Save", style: .Default, handler: { (alert: UIAlertAction!) -> Void in println("File Saved") }) // let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: { (alert: UIAlertAction!) -> Void in println("Cancelled") }) // 4 optionMenu.addAction(deleteAction) optionMenu.addAction(saveAction) optionMenu.addAction(cancelAction) // 5 self.presentViewController(optionMenu, animated: true, completion: nil) }
- an UIAlertController with the ActionSheet style is created
- two actions are created which can be added to the Alert Controller. Note the use of a closure inside the brackets of the handler parameter
- another action is created, this time with the Cancel style
- the actions are added to the Alert Controller
- The Alert Controller is presented.
Build and Run the project, click the button and select the different actions inside the Action Sheet.
'개발 > iOS' 카테고리의 다른 글
UITableView Section 헤더 고정 방지 (0) | 2016.04.26 |
---|---|
UIScrollview Delegate 종류 (0) | 2016.04.22 |
swift UITableView 예제 (0) | 2016.04.21 |
아이튠즈 커넥트 앱 상태 정보 (0) | 2016.04.15 |
Xcode 플러그인 관리툴 – Alcatraz Package Manager (0) | 2016.04.12 |
Comments