2014년 4월 11일 금요일

iOS 7에서 UITextView RETURN 시에 다음라인이 다 보이지 않고 라인과 캐럿이 걸쳐 보이는 현상

ios7에서 UITextView에 텍스트 입력시에 Return키를 입력하면 다음줄이 보이지 않고 프레임 밖으로 가려서 보이지 않는 현상


UITextViewDelegate 하수를 다음과 같이 작성.

- (void)textViewDidChangeSelection:(UITextView *)textView
{
    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
        if ([textView.text characterAtIndex:textView.text.length-1] != ' ') {
            textView.text = [textView.text stringByAppendingString:@" "];
        }
        
        NSRange range0 = textView.selectedRange;
        NSRange range = range0;
        if (range0.location == textView.text.length) {
            range = NSMakeRange(range0.location - 1, range0.length);
        } else if (range0.length > 0 &&
                   range0.location + range0.length == textView.text.length) {
            range = NSMakeRange(range0.location, range0.length - 1);
        }
        if (!NSEqualRanges(range, range0)) {
            textView.selectedRange = range;
        }
    }

}

2014년 4월 9일 수요일

back swipe gesture in UINavigationController on iOS 7





// enable
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;

}




// disable
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}



UIProgressView의 height 크게하기





- (void)viewDidLoad
{
...
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
_progressView.transform = transform;


...
}

2014년 4월 7일 월요일

locale에 따라 날짜와 시간 포멧 설정

포멧 문자 참조사이트 :
http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns



NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"yyyyMMMdahm0s" options:0 locale:[NSLocale currentLocale]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:formatString];


NSString *todayString = [dateFormatter stringFromDate:[NSDate date]];

addsubview animation

방법 1)

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                           forView:newView
                             cache:YES];
    [containerView setHidden:NO];
    [containerView addSubview:newView];
    [UIView commitAnimations];


방법 2)
    [UIView transitionWithView: containerView duration:0.5
                       options:UIViewAnimationOptionCurveEaseInOut 
                    animations:^ {
                        [containerView addSubview:newView];
                    } completion:nil];



방법 3)
CATransition *animation = [CATransition animation];
 [animation setDuration:0.2];
 [animation setType:kCATransitionMoveIn];
 [animation setSubtype:kCATransitionFromRight];
    [newView.layer addAnimation:animation forKey:nil];

    [containerView addSubview:newView];

2014년 4월 2일 수요일

bounce popup view 뛰우기




PlaceSearchPopupView *placeSearchPopup = [[PlaceSearchPopupView alloc] initWithFrame:CGRectMake(52, 32, 269, 200)];
    placeSearchPopup.center = CGPointMake(CGRectGetMidX(self.view.frame), CGRectGetMidY(self.view.frame));
    placeSearchPopup.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1);
    [popupView addSubview:placeSearchPopup];
    
    [UIView animateWithDuration:0.2 animations:^{
        placeSearchPopup.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.1 animations:^{
            placeSearchPopup.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.1 animations:^{
                placeSearchPopup.transform = CGAffineTransformIdentity;
            }];
        }];
    }];