전체 글76 버튼 이벤트 다른 컨트롤러의 func 불러오기 기본적으로 버튼 이벤트를 호출할때vNewComics.btnMore.addTarget(self, action: #selector(onTabBarChange), for: .touchUpInside) 이런식으로 호출한다. 근데 다른 컨트롤러의 func를 호출한다면 vNewComics.btnMore.addTarget(nil, action: #selector(HomeVC().onTabBarChange), for: .touchUpInside) 이런식으로 해야 한다! self -> nil로!func 는 Controller().func으로! 2016. 10. 21. UItableView 회전 tableviewName.transform = CGAffineTransform(rotationAngle: -(CGFloat)(M_PI_2)) 이런식으로 쓰면 된다 2016. 10. 14. [Swift]UIGestureRecognizer 참고자료 http://minsone.github.io/mac/ios/uigesturerecognizer 참고하여 나는 이런식으로 썼다! override func viewDidLoad() { super.viewDidLoad() initUi() let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(swipeGes:))) let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(swipeGes:))) swipeUp.direction = .up swipeDown.direction = .down self.view.gestureR.. 2016. 9. 28. swift3 numberOfSectionsInTableView swift 2.3 >> override func numberOfSectionsInTableView(tableView: UITableView) -> Int swift 3.0 >> override func numberOfSections(in tableView: UITableView) -> Int 원래 사용하던 swift 2.3 버전에서 개발을 계속하다가iOS 10이 출시되면서 xcode를 8로 업그레이드를 했다 하고 나니 어머나 문법이 왤케 많이 달라졌지?!ㅠㅠ그중 하나 고생한게 numberOfSectionsInTableView 이다.. 중간중간 비슷하지만 살짝살짝씩 다른게 있으니 주의할것!! 2016. 9. 19. Loaded nib but the view outlet was not set 오류 해결법 1. files owner와 제대로 연결되었는지 확인할 것 (이름 확인!!)2. view를 연결시켜줄것!! You guys are right, but as I'm a newcomer it took me a little while to figure out all the steps to do that. Here's what worked for me:Open the XIB file causing problemsClick on file's owner icon on the left bar (top one, looks like a yellow outlined box)If you don't see the right-hand sidebar, click on the third icon above "view" in you.. 2016. 9. 19. Choose an initial devise view ; devise 사이즈 변경 Xcode 8로 업그레이드를 한 후 기존의 프로젝트에서 Xib파일을 열었을때, 아래와 같은 경고창이 떠서 놀랬다. 영어로 쏼라쏼라... 초기화 할 디바이스를 선택하라길래 나는 아이폰 6s 플러스를 기준으로 하고있으나, 변경 가능하다는 안내 메시지를 보고 그냥 6s를 했는데.. 어라 이거 어떻게 바꾸지? 한참의 삽질끝에.. 발견한 것..!! 너무 조그매서 보이지도 않는다!! 에라잇!! 저걸 누르니 여러 기기들이 나온다. 이전 버전에 익숙한 나로서는 넘나 불편한것 ㅠㅠㅠㅠㅠㅠ 열심히 공부해야겠다..... 2016. 9. 19. lazy is only vaild for member of struct of class swift로 개발중에 메모리 낭비 방지를 위해 테이블의 이미지를 늦게 출력하게 하려고 lazy 키워드를 사용하려고 했다 하지만 에러가 났다 lazy is only vaild for member of struct of class 검색해보니 해당 lazy키워드는 func안에 넣을 수 없고 클래스 안에 글로벌하게만 쓸수 있다.. 2016. 9. 6. 테이블 맨 위로 올리기(top) @IBAction func GoTop(sender: AnyObject) { tableview.setContentOffset(CGPointZero, animated: true) } 2016. 9. 5. 빈공간 터치시 키보드 내리기 override func touchesBegan(touches: Set, withEvent event: UIEvent?) { userIDField.resignFirstResponder() userPWField.resignFirstResponder() } 2016. 8. 31. UIViewController에서 Table사용하기 UIViewController에서 Table사용하는 법은 UITableViewController에서 사용하는 것과 다를 바가 없다.그저 override키워드를 빼는 것일뿐! import UIKit class BookListController : UIViewController{ let list = (try! Realm().objects(User.self).last?.products)! //사용자의 보관함 목록을 불러옴 override func viewDidLoad(){ super.viewDidLoad() } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.list.count //갯수반.. 2016. 8. 31. Unrecognized selector sent to instance 에러 Unrecognized selector sent to instance 블라블라 이러한 에러메시지가 뜬다면..연결된 변수명이나 오래된 관계 속에서 잘못된것이 있을수 있으니 연결을 끊고 다시 연결해볼것! 분명 변수명이 변경된 경우 변경 전의 변수와 연결되고, 바뀐 변수와 연결되는 2중 연결이 있을수 있다! 2016. 8. 29. swift 사파리로 링크열기 UIApplication.sharedApplication().openURL(NSURL(string: "http://naver.com/")!) 을 입력해 주면 간단히 해결! 2016. 8. 24. Xcode가 느려지는 현상 방금 Xcode가 느려지는 현상을 경험했다. 코드를 쓰고, 스토리보드를 수정하는 과정에서 너무 느렸다. 특이한건, 같이 사용하고 있는 크롬과 카카오톡 등 다른 프로그램은 빠르게 돌아갔다.. 뭐지.. 당황해서 맥북을 너무 오래켜놨나 해서 2번정도 재부팅을 했지만 동일한 현상을 겪었다. 활성상태로 보기 하니계속 Xcode만 높은 점유율을 가지고 있었다. 이럴 때는 스토리보드 파일을 띄우고 있다면 다른화면을 띄워보길 바란다. Xcode자체가 여타 다른 visual studio 같은 프로그램보다 안정적인 프로그램이 아니며, 스토리보드 내에서 인터페이스가 우리도 모르게 버그가 있을 수 있다. 또는 최근에 수정한 인터페이스나 코드를 지워보길 권장한다. 예전엔 안그랬으나 갑자기 느려진다면 최근에 수정한 것들이 오류를.. 2016. 8. 24. navigation bar에 로고 넣기(이미지 삽입) navigation bar에 로고를 넣고싶다면 1) 로고의 이미지 크기가 적절치 않을경우 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20)) imageView.contentMode = .ScaleAspectFit let image = UIImage(named: "YOURIMAGE") imageView.image = image navigationItem.titleView = imageView } 2) 로고의 이미지 크기를 적절하게 제작하였을 .. 2016. 8. 23. 탭바에 아이콘만 남기는 법 탭바에 아이콘만 남기고 싶다면image inset에 top 6, bottom -6을 적용하자! 2016. 8. 23. 이전 1 2 3 4 5 6 다음 반응형