Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / snippet.m
Created December 20, 2013 04:45
objective-c : UITextView 텍스트 한 칸 앞으로 또는 뒤로 가기
//텍스트 한 칸 앞으로 가기
-(void)gotoPrevChar
{
UITextRange *selectedRange = [self.noteTextView selectedTextRange];
//Calculate the new position, - for left and + for right
if (self.noteTextView.selectedRange.location > 0) {
@keicoder
keicoder / memo.txt
Last active January 1, 2016 00:08
memo : Online Dev Tutorial Site
Online Dev Tutorial Site
video2brain https://www.video2brain.com
tutsplus https://tutsplus.com
lynda http://www.lynda.com
pluralsight http://pluralsight.com
Infinite Skills http://www.infiniteskills.com
udemy https://www.udemy.com
teamtreehouse http://teamtreehouse.com
@keicoder
keicoder / snippet.m
Created December 23, 2013 04:43
objective-c : UiTableView Deleting rows (테이블 뷰 행 삭제)
UiTableView Deleting rows (테이블 뷰 행 삭제)
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{

[items removeObjectAtIndex:indexPath.row]; //1. remove the item from data model:
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic]; //2. delete the corresponding row from the table view
}
@keicoder
keicoder / snippet.m
Last active January 1, 2016 04:29
objective-c : UiTableView Static cell disable selections for row (정적 셀에서 셀 선택 허용하지 않기)
UiTableView Static cell disable selections for row (정적 셀에서 셀 선택 허용하지 않기)
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

return nil; //returning nil, delegate answers : “Sorry, but you’re not allowed to!”
}
* One more thing todo : Storyboard editor, select the table view cell and go to the Attributes Inspector. Set the Selection attribute to None.
now impossible to select the row and make it turn blue.
@keicoder
keicoder / snippet.m
Last active January 1, 2016 06:48
objective-c : UITextField 텍스트 유무에 따라 액션 버튼 활성화 판단
UITextField 텍스트 유무에 따라 액션 버튼 활성화 판단
- (BOOL)textField:(UITextField *)theTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *newText = [theTextField.text stringByReplacingCharactersInRange:range withString:string];
if ([newText length] > 0) {
self.doneBarButton.enabled = YES;
} else {
self.doneBarButton.enabled = NO;
}
@keicoder
keicoder / snippet.m
Last active January 1, 2016 06:49
objective-c : 기본적인 delegate pattern
기본적인 delegate pattern
//steps for setting up the delegate pattern between two objects,
//where object A is the delegate for object B and object B will send out the messages:
//1.Define a delegate @protocol for object B.
//2.Give object B a property for that delegate protocol.
//3.Make object B send messages to its delegate when something interesting happens, such as the user pressing the Cancel or Done buttons, or when it needs a piece of information.
//4.Make object A conform to the delegate protocol. It should put the name of the protocol in its @interface line and implement the methods from the protocol.
//5.Tell object B that object A is now its delegate.
@keicoder
keicoder / snippet.m
Created December 24, 2013 02:44
objective-c : put check mark on UITableView Cell (테이블 뷰에 체크마크 넣기)
put check mark on UITableView Cell (테이블 뷰에 체크마크 넣기)
//first :
//Add a new label to the cell to the left of the text label. Give it the following attributes:
//Text: √ (you can type this with Alt/Option+V) • Font: System Bold, size 22
//Autoshrink: No
//Highlighted color: White
//Tag: 1001 //give label its own tag, so can easily find it later.
- (void)configureCheckmarkForCell:(UITableViewCell *)cell withChecklistItem:(ê ChecklistItem *)item {
@keicoder
keicoder / snippet.m
Last active January 1, 2016 06:59
objective-c : UITableView Cell의 Detail Disclosure 버튼에 Segue 적용
UITableView Cell의 Detail Disclosure 버튼에 Segue 적용 (for iOS 5)
//Note: As of Xcode 4.5 and iOS 6 you can now make segues directly from accessory buttons.
//When you Ctrl-drag from the table view cell,
//Xcode asks you whether you want to put the segue on the whole cell or just the accessory button.
//this new feature is not compatible with iOS 5
//first :
//table view cell in the Storyboard editor and in the Attributes Inspector set its Accessory to Detail Disclosure.
//Ctrl-drag from the ChecklistsViewController icon in the dock area to the Navigation Controller and make a Modal segue:
@keicoder
keicoder / snippet.m
Last active April 7, 2024 13:08
objective-c : iOS 7 스토리보드 대신 xib 방식으로 개발하기
//iOS 7 스토리보드 대신 xib 방식으로 개발하기
//solution 1
1. empty application 생성
2. new class file 생성 -> name : ViewController, UIViewController sub class, with XIB check
3. appdelegate 헤더 파일 수정
@class ViewController;
@property (strong, nonatomic) ViewController *viewController;
4. appdelegate m 파일 수정
@keicoder
keicoder / snippet.m
Created December 26, 2013 05:45
objective-c : UITextView 생성, 델리게이트 메소드
UITextView 생성, 델리게이트 메소드
#import <QuartzCore/QuartzCore.h>
.h 파일
@interface 에서 <UITextViewDelegate> 명시
.m 파일
#pragma mark - 뷰 라이프 사이클