본문 바로가기

Swift

(57)
3D 화면전환 튜토리얼 http://www.appcoda.com/custom-view-controller-transitions-tutorial/
if case 예제 갑자기 귀차니즘이 발동하여 배열을 받아왔는데 배열이 nil은 아닌데 안에 건수가 0이 아닌지도 한 방에 체크하고 싶다.이런게 있을까? 해서 찾아보았더니 있다.바로 if case 구문이다. let realms = Realms()if case let cnt = realms.countTB_LEVEL() where cnt == 0 { _ = ImportJSON() }
문자열 메소드 참조 사이트 ios String method iOS 문자열 관련 메소드 잘 정리된 글 참조 http://meetkei.com/?p=804
불필요한 비어있는 tableview cell 안 보이게 하기 불필요하게 빈 칸인 테이블뷰의 셀이 보이는 경우가 있다. 이게 보기 싫다면 다음과 같은 꼼수로 안 보이게 할 수 있다.바로 tableFooterView를 설정함으로써 이런 효과를 거둘 수 있다.아래 코드를 viewDidLoad 등에 넣어주면 된다. let footerView = UIView() footerView.backgroundColor = UIColor.clearColor() levelTableView.tableFooterView = footerView
UITableView cell의 background color 변경시 문제 UITableViewCell에서 특정 값에 따라 Cell의 BackgroundColor가 변경되어야 한다. 허나 이 변경에 있어서 처음에 color 설정을 tableView(cellForRowAtIndexPath:) 에서 해 주었는데 셀 내용이 갱신되고 셀을 스크롤하다보니 점점 color가 이상한 cell에까지 설정이 되는 것이었다. 그래서 이번에는 color 설정을 tableView(willDisplayCell:) 여기서 해 주었는데, 뭔가 되는 것 같아 보이더니 더 금방 다른 셀의 색까지 바꿔버리는 현상이 발생하였다. 곰곰히 생각해보니 내 셀을 바꾸는 코드가 if !cell.result { cell.backgroundColor = UIColor.orangeColor()}이거였는데 현상을 보니 나중에는..
array.map과 tableView의 갱신 update Realm을 사용하다보니 테이블뷰를 갱신할 일이 생겼다. 그런데 샘플로 참고하는 코드에서 테이블뷰를 갱신하면서 map을 사용하는 것이다. 처음에는 도대체 이게 뭔지 몰라서 한참 고민했는데 여기저기 검색하다보니 알게 되었다. func rightBarButtonPressed() { filterDate = NSCalendar.currentCalendar().dateByAddingUnit(.Day, value: -1, toDate: filterDate, options:NSCalendarOptions(rawValue: 0))! dateFormatter.dateFormat = "yyyy.MM.dd" let colDate = dateFormatter.stringFromDate(filterDate) filterDate..
A Beginner’s Guide to NSDate in Swift NSDate에 대한 기똥찬 글을 발견. : http://www.appcoda.com/nsdate/ 2015년 10월 글이라 아직 따끈따끈한 글이다. 이 글이 사라질까 두려워 여기에 저장해 놓는다. If I was ever asked what’s one of the most common stuff I do among all projects, then I would have answered that dealing with dates is definitely one of them. Undoubtably, there’s no developer out there who doesn’t really need to “play” with the NSDate class and handle dates in some mann..
NavigationBar의 Hidden / Show 전환 (UPDATE: 5시간 가량의 삽질 후 알게된 내용)이 현상은 Main.Storyboard의 버그라고 생각된다. 상세 원인은 이 글 제일 아래에 작성하였다. 겁나 간단한 개념인데 이게 잘 안 된다. 하고 싶은 것은 View 1 -> 2 -> 3 -> 4가 있는데 View1에서는 NavigationBar가 보이고 View2에서 hidden이 되었다가 3, 4에서는 다시 보여지는 것이다. 1. View1당연히 View1에서는 Navi Bar가 잘 보여진다. 2. View2viewDidLoad() 에서 self.navigationController?.setNavigationBarHidden(false, animated: true)를 주거나 아예 이 문장을 넣지 않은 상태에서viewWillAppear()에서 s..