'iPhone'에 해당되는 글 170건

  1. 2013.11.20 [objc] OHAttributedLabel, auto link 추가 삭제
  2. 2013.11.19 [objc] block, 큐, 병렬처리
  3. 2013.11.18 [objc] 인터넷 커넥션 체크
  4. 2013.11.14 [objc][Err] AFURLConnectionOperation.operationDidStart, Bad Access
  5. 2013.11.11 [objc] 대소문자 구분없이 검색/치환
  6. 2013.10.25 [objc] UITabBar 숨기기/보이기
  7. 2013.10.18 [objc] block을 파라메터로 받기
  8. 2013.10.01 [objc] NSAttributedString
  9. 2013.09.30 [objc] iOS7, xcode5, layout 문제
  10. 2013.09.27 [objc] OS version check
  11. 2013.09.25 [mac] 영역 복사
  12. 2013.09.21 [objc] image 나인패치 효과
  13. 2013.09.18 [objc] Test Flight
  14. 2013.09.17 [???] 나인패치 왜 안먹지..?
  15. 2013.09.17 [???] 스토리보드의 UI오브젝트 origin, size값 수정 문제
  16. 2013.09.14 [obcj] UIButton, underline
  17. 2013.09.14 [objc] NSRange, 문자열로 범위 지정
  18. 2013.09.14 [objc] UIButton에 NSAttributedString 적용
  19. 2013.09.14 [objc] UIButton, title text 바꾸기
  20. 2013.09.14 [objc] OHAttributedLabel 높이 계산 문제, NSAttributedString
  21. 2013.08.28 [objc] UITextField, left margin
  22. 2013.08.22 [objc] 매크로선언, #if
  23. 2013.08.22 [objc] storyboard 복사
  24. 2013.08.16 [objc] define 배열
  25. 2013.08.15 [objc] UINavigationBar, back button 숨기기
  26. 2013.08.15 [objc] do something when app ApplicationWillResignActive
  27. 2013.08.15 [objc] UINavigationController에서 UIViewController 얻기
  28. 2013.08.12 [objc] AssetsLibrary sample
  29. 2013.07.29 [objc] link를 포함함 Label
  30. 2013.07.26 [objc] NSString, replace




// 디폴트 링크 전부 삭제

[self.ohlabel setAutomaticallyAddLinksForType:0];



//링크만 체크 (숫자로 전화걸리는 링크는 삭제하고 싶을때)

[self.ohlabel setAutomaticallyAddLinksForType:NSTextCheckingTypeLink];






참고링크


**문자열로부터 URL, 전화번호를 취득.

http://www.sirochro.com/note/objc-nsdatadetector-using/


** 링크 기능 죽이기

https://github.com/AliSoftware/OHAttributedLabel/issues/112

Posted by tenn
,


** Global Queue

    dispatch_queue_t syncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT0);

    dispatch_async(syncQueue, ^{

});


** Main Queue


dispatch_async(dispatch_get_main_queue(), ^{

        });



** private Queue


dispatch_queue_t queue;
queue = dispatch_queue_create("com.example.MyQueue", NULL);




************


Simple block sample

int x = 123;
int y = 456;
 
// Block declaration and assignment
void (^aBlock)(int) = ^(int z) {
    printf("%d %d %d\n", x, y, z);
};
 
// Execute the block
aBlock(789);   // prints: 123 456 789

https://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html

************

...Block:(void(^)(int b, intc))block{

     block(1, 2);

}

Posted by tenn
,

#import "Reachability.h"


+ (BOOL)isConnectedToInternet

{

    Reachability *reachability = [Reachability reachabilityForInternetConnection];

    return NotReachable != [reachability currentReachabilityStatus];

}

Posted by tenn
,

bundler identifier에 이상한 문자가 들어가면


AFURLConnectionOperation에서 Bad Access로 기동이 안되고,

어플이 강제종료 되는 현상이 있다.


XCode5

iOS5, iOS6에서 현상 있음.

iOS7에서는 문제없음.

Posted by tenn
,


[mystring stringByReplacingOccurrencesOfString:@"searchString" withString:@"replaceString" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mystring length])];


http://stackoverflow.com/questions/6236581/how-to-replace-a-case-insensitive-string-in-objective-c-iphone





Posted by tenn
,



탭바를 숨기기/보이기를 할때, UIView를 늘여서 움직임을 만들면,

iOS5/6에서 탭바영역이 화면을 가리는 현상이 발생.

iOS7에서는 문제없이 동작.

삽질하다가 좋은 예문을 찾음.


http://stackoverflow.com/questions/5272290/how-to-hide-uitabbarcontroller


// Method implementations
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];

    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
        }
    }

    [UIView commitAnimations];   
}

- (void)showTabBar:(UITabBarController *) tabbarcontroller
{       
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        NSLog(@"%@", view);

        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];

        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
        }
    }

    [UIView commitAnimations]; 
}


Posted by tenn
,



-(void) aaa:(void(^)(id abc))complete{



}


- (void)bbbWithComplete:(void(^)(void))success{

}




Posted by tenn
,

[objc] NSAttributedString

iPhone 2013. 10. 1. 10:56



    NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString:str];

str가 nil일 경우, 앱에 종료된다.


Posted by tenn
,

xcode5에서 빌드할때, 

레이아웃에 문제가 생기는 경우.

크게 두가지로 나뉜다.


1. 스테이터스바 침식

2. 네비게이션바 침식


해결책으로 이하의 자료를 발견

http://qiita.com/cyan_ishii/items/0babccb20c0f183b1c5f


하지만 잘 듣지 않았다.

iOS7에서는 표시가 바르게 되었지만,

iOS6이하에서는 레이아웃이 전체적으로 위로 밀리는 현상이 발생.

예전의 방법으로 뷰컨트롤러의 뷰의 프레임을 임의로 조정하거나.

스토리보드에서 델타(iOS 6/7 Deltas)를 조정해도 반영되지 않았다.


뷰컨트롤러의 뷰에 다시 레이아웃용의 뷰를 올려서 레이아웃을 구성하면,

레이아웃용 뷰는 조정이 먹으므로(스토리보드의 델타보정도 가능)

해결.(진짜?)


추가 > 

다필요없고.

iOS7미만에서 이상있는 것은

사용하는 네비게이션 컨트롤러에서 translucent의 체크를 해제해주면 된다.

스토리 보드에서 네비게이션컨트롤러안에 있는 네비게이션 바를 선택하면 선택 체크박스가 나타난다.

특히 네비게이션 갈아타고 다니는 경우에 스토리보드에서 네비게이션바 다 찾아서 해제해줘야 한다.


iOS5/6에서도 네비게이션 바가 투명하면 화면이 바 밑으로 들어간다고 한다.


Posted by tenn
,

[objc] OS version check

iPhone 2013. 9. 27. 12:44



#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

and use them like this:

if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
    // code here
}

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
    // code here
}





http://stackoverflow.com/questions/7848766/how-can-we-programmatically-detect-which-ios-version-is-device-running-on

Posted by tenn
,

[mac] 영역 복사

iPhone 2013. 9. 25. 14:09

option + 드래깅 : 원하는 영역을 선택할 수 있다

Posted by tenn
,


- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets


가로로 늘릴 때는 UIEdgeInsets의 top, bottom은 0.


참고 : http://www.appcoda.com/customize-navigation-bar-back-butto/

(그림 보면 이해가 쉬움)



** 다음의 경우에는 쓰면 안됨.

중간 부분의 이미지가 질감인 경우. (타일패턴으로 채우기때문에 부자연스럽게 보임)





Posted by tenn
,

[objc] Test Flight

iPhone 2013. 9. 18. 16:51



Test Flight 어플리를 설치하려면?

앱스토어에 없더라??


여기서 로그인하면,

앱 설치하는 url이 나옴.

https://www.testflightapp.com/m/login



http://help.testflightapp.com/customer/portal/articles/829782-does-testflight-have-an-app-on-the-app-store-?t=233980?topicname=Mobile

Posted by tenn
,


따라해봐도 안먹네..


https://github.com/mixi-inc/iOSTraining/wiki/3.1-UIView

Posted by tenn
,

새로 프로젝트를 생성해서 스토리보드를 보니 뭔가 많이 바뀌어있다...

스토리보드의 UI오브젝트의 frame의 값을 고쳐도 먹지를 않는다.

코드에서 생성한 UI오브젝트는 중간에 고쳐도 잘 먹는데...

Size Inspector의 GUI가 뭔가 변했는데 관계가 있는듯?

constraints가 더덕더덕 붙어있는게... ;;

Posted by tenn
,

[obcj] UIButton, underline

iPhone 2013. 9. 14. 16:35



NSMutableAttributedString *attrStr = [[NSMutableAttributedString allocinitWithString:@"ボタン"];

    NSDictionary *attributes = @{                                 NSUnderlineStyleAttributeName@(NSUnderlineStyleSingle)};

    [attrStr addAttributes:attributes

                     range:NSMakeRange(0, attrStr.length)];

    

    [self.btn setAttributedTitle:attrStr forState:UIControlStateNormal];


    

Posted by tenn
,


NSString *str = @"part1 part2 part3";

NSRange range = [str rangeOfSring:@"part2"];


Posted by tenn
,





    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"ボタン"];

    

    /* フォント */

    [attrStr addAttribute:NSFontAttributeName

                    value:[UIFont fontWithName:@"ChalkboardSE-Regular" size:30.f]

                    range:NSMakeRange(0, attrStr.length)];

    /* 文字色 */

    [attrStr addAttribute:NSForegroundColorAttributeName

                    value:[UIColor cyanColor]

                    range:NSMakeRange(0, attrStr.length)];


    

    // 中抜き文字の枠線の色、下線、カーニングを一度に指定

    NSDictionary *attributes = @{NSStrokeColorAttributeName: [UIColor magentaColor],

                                 NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),

                                 NSKernAttributeName: @1.5};

    

    NSString *tStr = @"ボタン";

    

    [attrStr addAttributes:attributes

                     range:[tStr rangeOfString:@""]];





Posted by tenn
,



[yourButton setTitle:@"your title" forState:UIControlStateNormal];

[yourButton setTitle:@"your title" forState:UIControlStateSelected];

[yourButton setTitle:@"your title" forState:UIControlStateHighlighted];


Posted by tenn
,

UILabel을 사용할 때 NSString의 sizeWithFont를 사용하듯,

OHAttributedLabel을 사용하면, 자간의 차이 때문에 (일본어를 사용할 시에행간이 달라짐)

height의 결과가 달라진다.

특히 테이블에 넣었을 때, 애로사항이 꽃핀다.


해결방법으로는 구글 선생님과 상담결과 행간을 조절한다. 라고 하는데

뭘 잘못했는지 잘 안됨.

http://eikatou.net/blog/2012/09/ios_rich_uilabel_2/


CoreText의 버그라는 말도 보인다.

http://cafe.naver.com/mcbugi/255603

일본어의 문제는 인식하고 있지만, 영어의 문제는 확인하지 않았다.


//행간을 조절할 수 있다는데 테스트해보지 않음.

NSMutableAttributedString *attributedString;

attributedString = [[NSMutableAttributedString alloc] initWithString:str];

// [attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)];

http://stackoverflow.com/questions/7370013/how-to-set-kerning-in-iphone-uilabel



다른 방법이 없는 지 몇시간을 파닥대다가...

OHAttributedLabel에 문자열을 넣을 때, NSString이 아닌 NSAttributeString을 넣고,

계산할 때, NSAttributedString의 sizeConstrainedToSize를 사용하면, 달라진 자간에 대한 정확한 결과를 얻을수 있는 듯하다. 

간이테스트에는 그럴듯한 결과가 나왔지만, 실제 어플에 넣었을 때 어떻게 될지 확인해 보아야하겠다.




Posted by tenn
,


UITextField의 외곽선을 이미지로 했을 때, 고민하게 되는 문제.


UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;


http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone

Posted by tenn
,

[objc] 매크로선언, #if

iPhone 2013. 8. 22. 16:08


http://blog.naver.com/PostView.nhn?blogId=yongsu0207&logNo=110109211098&parentCategoryNo=7&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView

Posted by tenn
,

[objc] storyboard 복사

iPhone 2013. 8. 22. 15:14

스토리보드에서 스토리보드로 복사할때,

안의 컴포넌트의 좌표와 크기가 흐트러질 때가 있다.


storyboard > Interface Builder Document > use AutoLayout

을 비활성화 하면, 스토리복사를 해도 좌표정보가 변하지 않는다.

Posted by tenn
,

[objc] define 배열

iPhone 2013. 8. 16. 18:30



#define ARRAY @[@"array1",@"array2", @"array3"]

Posted by tenn
,




self.navigationItem.hidesBackButton = YES;

따위도 안먹고 곤란할 때.



    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

    UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

    button.hidden = YES;

    self.navigationItem.leftBarButtonItem = customBarItem;


이게 되더라..




//////

self.navigationItem

self.navigationController.navigationItem


Posted by tenn
,

http://books.google.co.jp/books?id=_n9WXhy_xjAC&pg=PA151&lpg=PA151&dq=objc+do+something+when+enter+background&source=bl&ots=ArDjYSa1qd&sig=KNYGWzmEwhuJde2Q4gtFSPoUfz8&hl=en&sa=X&ei=LjkMUpnkG4zOkwWVtIE4&ved=0CHcQ6AEwCDgK#v=onepage&q=objc%20do%20something%20when%20enter%20background&f=false

Posted by tenn
,





UIViewController *targetView = [[self.navigationController viewControllers] objectAtIndex:0];  

//0(root)〜depth



Posted by tenn
,

[objc] AssetsLibrary sample

iPhone 2013. 8. 12. 14:44



http://pentacreation.com/blog/2012/12/121208.html

Posted by tenn
,


link색깔을 바꿀수도 있음.

height 조절할 때, 먼저 최대화 해준후, sizeToFit


OHAttributedLabel


https://github.com/AliSoftware/OHAttributedLabel

Posted by tenn
,

[objc] NSString, replace

iPhone 2013. 7. 26. 12:41
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target 
                                        withString:(NSString *)replacement


http://stackoverflow.com/questions/668228/string-replacement-in-objective-c

Posted by tenn
,