'iPhone'에 해당되는 글 170건

  1. 2014.03.03 [objc] Appirater, 앱평가 알림 라이브러리
  2. 2014.02.26 [objc] NSDate 날짜비교
  3. 2014.02.26 [objc] singleton, sharedInstance, 싱글톤
  4. 2014.02.25 [objc] #define 대신에 const를 써보자
  5. 2014.02.25 [objc] property 있는데 셀렉터 없다고 하면서 죽을 때
  6. 2014.02.24 [objc] 디바이스가 iPhone5s인가 체크, device model
  7. 2014.02.20 [objc] xib와 커스텀 UIView 만들기
  8. 2014.02.19 [pod] pod가 문제를 일으킬 때
  9. 2014.02.18 [c] c style array
  10. 2014.02.07 [objc] 본문에 이미지 포함시키기, 본문보다 이미지를 앞에 위치시키고 싶을때
  11. 2014.01.17 [objc] push 메세지를 클릭해서 앱을 실행시킬 경우
  12. 2014.01.17 [objc] UTC시간 관련
  13. 2014.01.13 [objc] gesuture, tap, 눌렀을때 이벤트
  14. 2014.01.10 [objc] UIView, animation, 애니메이션이 끝난후 다른 애니메이션
  15. 2014.01.08 [objc] UITableView, 특정셀로 스크롤 시키기
  16. 2014.01.06 [objc] NSDate를 인수로 할 때, 제한을 두지 않고 싶을 때,
  17. 2014.01.06 [objc] sleep, CurrentRunLoop
  18. 2014.01.03 [objc] status bar
  19. 2013.12.28 [objc] 앨범에서 마지막으로 찍은 사진 가져오기
  20. 2013.12.27 AVCaptureSession, AVCaptureDevice, BAD ACCESS, crash
  21. 2013.12.25 [objc] NSMutableArray, 순서
  22. 2013.12.12 [objc] 아이폰 디바이스 체크 (iPhone5S체크에)
  23. 2013.12.12 [objc] 일정시간후 block 실행
  24. 2013.12.11 linker command failed with exit code 1
  25. 2013.12.06 [objc] NSArray 순서 랜덤하게 바꾸기
  26. 2013.12.04 [xcode] framework추가하는데 엄한 곳에서 계속 에러가 날때
  27. 2013.12.03 [objc] UIWebView, 길게탭 이벤트 죽이기
  28. 2013.12.02 [objc] xcode5, iOS5 프로젝트 만들면 에러-
  29. 2013.11.28 [objc] 화면이동 참고 자료
  30. 2013.11.21 [objc] UITabBar setHidden, 영역이 남는 문제







static NSString *_appId = @"593799029";

// 경고창이 표시될때까지의 날짜

static double _daysUntilPrompt = 5;

// 경고창이 표시될때까지의 기동회수

static NSInteger _usesUntilPrompt = 20;

//특정의 조건으로 경고창을 표시하고 싶을 때

static NSInteger _significantEventsUntilPrompt = -1;

// 나중에 를 선택했을 경우, 몇일후 경고창을 재표시할것인가를 지정

static double _timeBeforeReminding = 1;

//YES를 할 경우 매번 경고창을 표시

static BOOL _debug = NO;



http://programming-ios.com/objective_c-appirater-alert/

Posted by tenn
,

[objc] NSDate 날짜비교

iPhone 2014. 2. 26. 14:54







if ([date1 compare:date2] == NSOrderedDescending){


}



* NSOrderedSame : 같을때

* NSOrderedDescending :  date1가 date2보다 이후

* NSOrderedAscending :  date1이 date2보다 이전






http://stackoverflow.com/questions/5965044/how-to-compare-two-nsdates-which-is-more-recent

Posted by tenn
,





+ (ClassType*)sharedInstance{

      static ClassType *instance;

static dispatch_once_t predicate;

dispatch_once(&predicate, ^{

instance = [[ClassType alloc] init];

});

return instance;

}




Posted by tenn
,

http://www.objectivec-iphone.com/introduction/const/define-const.html

Posted by tenn
,



property 선언을 메소드 선언 뒤에서 하면 안된다...

Posted by tenn
,

#import <sys/sysctl.h>


    size_t size;

    sysctlbyname("hw.machine"NULL, &size, NULL0);

    char *machine = malloc(size);

    sysctlbyname("hw.machine", machine, &size, NULL0);

    NSString *platform = [NSString stringWithUTF8String:machine];

    free(machine);

    

//iPhone5s의 경우,  platform이"iPhone6"


//angeOfString:@"iPhone6"].location != NSNotFound  <- 이렇게 체크





* iPod5th : iPod5,1

* iPhone4 : iPhone3,1

* iPhone4S : iPhone4,1

* iPhone5 : iPhone5,2

* iPhone5s : iPhone6,1



Posted by tenn
,


1. UIView를 계승한 클래스 만듦.


2. xib만듦


3. UIView에.. 추가


+ (id)customView

{

    CustomView *customView = [[[NSBundle mainBundleloadNibNamed:@"xibview" owner:nil options:nillastObject];

    

    // make sure customView is not nil or the wrong class!

    if ([customView isKindOfClass:[CustomView class]])

        return customView;

    else

        return nil;

}


4. xib의 Custom Class에 CustomView지정.


5. 사용



CustomView *cView = [CustomView customView];




Posted by tenn
,



http://stackoverflow.com/questions/21474536/podfile-gives-an-error-on-install

Posted by tenn
,

[c] c style array

iPhone 2014. 2. 18. 23:01




   int array[10];

    

    for(int i=0;i<10;i++){

        array[i] = 0;

        NSLog(@"%d", array[i]);

    }

    

    for(int i=0;i<10;i++){

        array[i] = i;

        NSLog(@"%d", array[i]);

    }


Posted by tenn
,

메일 타입을 HTML로 해서


이미지 데이터를 포함시킨다.

NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0f);
NSString *encodedString = [imageData base64Encoding];
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='https://t1.daumcdn.net/cfile/tistory/275C1D4656E67CA00C",encodedString]];

http://stackoverflow.com/questions/14859463/how-to-send-image-in-email-body

Posted by tenn
,


push 메세지를 클릭해서 앱을 실행시킬경우

두가지 경우에 대해 처리를 해주어야 한다.



1. 앱이 기동하지 않은 경우.


ApplicationDelegate의

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

메소드가 불린다.

launchOptions에 푸시메세지에서 설정한 정보를 얻을수 있다.


2. 앱이 기동하여 백그라운드에 있는경우.


-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

메소드가 불린다.

userInfo에 푸시에서 설정한 정보를 얻을수 있다.

앱이 포어그라운드에 있을 경우에도 핸들링이 되므로, 

푸시를 누를 경우에만 이벤트를 핸들링 하고 싶을 경우.

[application applicationState]을 조건으로 추가해주면 된다.




Posted by tenn
,

[objc] UTC시간 관련

iPhone 2014. 1. 17. 18:04


-(NSString *)getUTCFormateDate:(NSDate *)localDate

{

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];

    [dateFormatter setTimeZone:timeZone];

    [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

    NSString *dateString = [dateFormatter stringFromDate:localDate];

    return dateString;

}



"yyyy-MM-dd HH:mm:ss"

로 하면, 12시간 표시로 할 경우

로컬라이즈된 오전, 오후 표시가 된다.


Posted by tenn
,


TouchDown 잡아와서 터치지점의 CGPoint로 이벤트 핸들링을 할 일이 생겼는데..


UITapGesture에서 TouchUp이벤트를 주는 건 알겠는데

TouchDown을 하려고 보니까 뭔가 귀찮은게 있는 듯.

안드로이드에서는 쉬웠던거 같은데...

UIGesture로 하려고 하면 복잡하듯 해서,

touchesBegan에서 잡아서 하니까 된다...


http://stackoverflow.com/questions/3176304/get-touch-location-from-touchesbegan-and-other-game-questions



Posted by tenn
,




http://stackoverflow.com/questions/9235872/running-an-animation-one-after-the-other-fails

Posted by tenn
,



            NSIndexPath* ip = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];

            [tableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionTop animated:YES];




http://stackoverflow.com/questions/2156614/how-to-start-uitableview-on-the-last-cell

Posted by tenn
,




[NSDate distantFuture];

먼미래에...

최대치의 느낌으로 쓰자.


http://qiita.com/happy_ryo/items/db116859f105d8a2e178

Posted by tenn
,


어떤 이벤트/처리를 기다릴때,

sleep하면 처리자체가 멈추므로.

현재의 메인스레드 이외에는 멈추면 안됨.


그럴때, while문 사이에..


[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];





Posted by tenn
,

[objc] status bar

iPhone 2014. 1. 3. 16:48


스테이터스바 표시


if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {

    // iOS 7

    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];

} else {

    // iOS 6

    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

}


- (BOOL)prefersStatusBarHidden {

    return YES;

}



http://stackoverflow.com/questions/12661031/how-to-hide-a-status-bar-in-ios






스테이터스바 텍스트 컬러


 [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];



-(UIStatusBarStyle)preferredStatusBarStyle{ 

    return UIStatusBarStyleLightContent; 

}


http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7

Posted by tenn
,






    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

    

    // Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.

    [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {

        

        // Within the group enumeration block, filter to enumerate just photos.

        [group setAssetsFilter:[ALAssetsFilter allPhotos]];

        

        // Chooses the photo at the last index

        [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:([group numberOfAssets] - 1)] options:0 usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {

            

            // The end of the enumeration is signaled by asset == nil.

            if (alAsset) {

                ALAssetRepresentation *representation = [alAsset defaultRepresentation];

                UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullScreenImage]];

                [latestPhoto resizeImageToWidth:50];

                

                if (latestPhoto){

                    [self.imgBtn setBackgroundImage:latestPhoto forState:UIControlStateNormal];

                    [self.imgBtn setBackgroundImage:latestPhoto forState:UIControlStateHighlighted];

                }

            }

        }];

    } failureBlock: ^(NSError *error) {

    }];



http://stackoverflow.com/questions/8867496/get-last-image-from-photos-app

Posted by tenn
,

카메라 관련의 주의점


AVCaptureDevice observer를 추가할 때

다른 인스턴스라고 하더라도 같이 영향을 받는 듯.

계속 크래시 하길래, 조사했더니

AVCaptureDevice에 NSKeyValueObservingOptionNew를 등록하고는 해제해주지 않은 채로,

새로운 뷰컨트롤러에서 카메라를 쓰려고 할때 같은 옵저버를 등록하려고 하자.

BAD ACCESS에러로 크래쉬.


뷰가 사라지는 지점에서 해제해주자, 현상은 없어졌다.

Posted by tenn
,


    

NSArray *array = [NSArray arrayWithObjects:@"1",@"2",@"3", nil];

    

    NSMutableArray *dataArray = [NSMutableArray arrayWithArray:array];

    [dataArray addObject:@"4"];

    

    NSArray *array2 = [NSArray arrayWithObjects:@"5",@"6",@"7", nil];

    

    [dataArray addObjectsFromArray:array2];

    

    

    for(NSString *str in dataArray){

        NSLog(@"%@", str);

    }




결과


2013-12-25 14:38:54.899 TestPrj[2030:70b] 1

2013-12-25 14:38:54.901 TestPrj[2030:70b] 2

2013-12-25 14:38:54.901 TestPrj[2030:70b] 3

2013-12-25 14:38:54.902 TestPrj[2030:70b] 4

2013-12-25 14:38:54.902 TestPrj[2030:70b] 5

2013-12-25 14:38:54.902 TestPrj[2030:70b] 6

2013-12-25 14:38:54.903 TestPrj[2030:70b] 7



Posted by tenn
,

- (NSString *) platform

{

    size_t size;

    sysctlbyname("hw.machine", NULL, &size, NULL, 0);

    char *machine = malloc(size);

    sysctlbyname("hw.machine", machine, &size, NULL, 0);

    NSString *platform = [NSString stringWithUTF8String:machine];

    free(machine);

    return platform;

}



http://iphonedevsdk.vanillaforums.com/forum/iphone-sdk-development/88107-getting-the-model-of-the-device.html


Posted by tenn
,




dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
    ...
});




http://stackoverflow.com/questions/4139219/how-do-you-trigger-a-block-after-a-delay-like-performselectorwithobjectafter

Posted by tenn
,

오늘의 0.5를 허공에 날려보낸...

linker command failed with exit code 1

!!!



Posted by tenn
,

셔플!


http://stackoverflow.com/questions/56648/whats-the-best-way-to-shuffle-an-nsmutablearray

Posted by tenn
,



프레임워크를 추가했는데 

추가한 프레임워크가 아닌 다른곳에서 계속 에러가 난다.

프로젝트의 복사본으로 여러차례 테스트해본결과,

프로젝트안의 프로젝트에서 프레임워크로 쓰는 xxx.a파일이 생성되어있지 않은것을 확인.

컴파일로 xxx.a파일을 생성해서 link binary framework의 빨간색을 다 없애자 문제가 해결됨.


-> 해결안됨.

프로젝트 파일의 변경을 조사한 결과

FRAMEWORK_SEARCH_PATHS에서


-                                       "\"$(SRCROOT)/FacebookSDK\"",

+                                       "\\\\\\\"$(SRCROOT)/FacebookSDK\\\\\\\"",

가 되어있는 것을 발견.

원래대로 돌려주니까,빌드 성공.

xcode의 버그인듯?


Posted by tenn
,

- (void)webViewDidFinishLoad:(UIWebView *)webView{

    // 링크 길게 누르면 나오는 메뉴를 안나오게

    [self.webview stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];

    // 길게 눌러서 선택 안되게

    [self.webview stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];

    

}

Posted by tenn
,

xcode5, iOS5


iOS5에서만 정상적으로 작동해서, 

움직임을 확인하려고, 프로젝트를 만들려고 했더니,

빌드타겟을 iOS5로 하고 실행시키면,

스토리보드 못찾겠다고 에러가 난다.


일단, 실행되게 하려면,

http://need-bee.com/b/2013/08/could-not-find-a-storyboard-in-xcode-5-for-ios-5-0/



근데, 실행은 되는데 스토리보드에 있는 콤포넌트들을 못읽어오네?..

그냥 코드로 만들어 붙여서 테스트 했다.



Posted by tenn
,



화면 이동시에 불려지는 메소드

http://iphone-dev.g.hatena.ne.jp/tokorom/20100110/1263150473

Posted by tenn
,



요롷고롬 하면 됨.


    CGRect rect = /* FULL SCREEN */;

    [[self.tabBarController.view.subviews objectAtIndex:0] setFrame:rect];



    [self.tabBarController.tabBar setHidden:YES];

    [[self.tabBarController.view.subviews objectAtIndex:0] setFrame:self.tabBarController.view.frame];







http://stackoverflow.com/questions/2426248/uitabbar-leaves-a-white-rectangle-when-hidden

Posted by tenn
,