반응형
- (CGFloat)safetyAreaHeight {
    if (@available(iOS 11.0, *)) {
        UIEdgeInsets edgeInsets = [UIApplication sharedApplication].windows[0].safeAreaInsets;
        if (edgeInsets.top != 0 && edgeInsets.bottom != 0) {
            CGFloat height = [UIApplication sharedApplication].windows.firstObject.safeAreaInsets.top;
            return height;
        }else{
            return 20;
        }
    } else {

        return 20;
    }
    return 20;
}

NON-Notch - 20px

pro가 45

mini가 50으로 영역이 더 큼. 참고

'Programing' 카테고리의 다른 글

[SWIFT] SceneDelegate 없이 AppDelegate로 프로젝트 구현  (0) 2023.07.10
AWS/Ubuntu EC2 셋팅  (0) 2023.06.30
[iOS] WKWebview User Agent 설정  (0) 2022.02.18
[iOS] klip sdk 적용이슈  (0) 2022.02.09
CRUL 관련  (0) 2021.12.02
Posted by npre
,
반응형

//    네비타이블 색상변경

    CGRect frame = CGRectMake(0, 0, 400, 44);

    UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];

    label.backgroundColor = [UIColor clearColor];

    label.font = [UIFont boldSystemFontOfSize:20.0];

    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0];

    label.textAlignment = UITextAlignmentCenter;

    label.textColor = [UIColor whiteColor];

    label.text = self.navigationItem.title;

    

    [self.navigationItem setTitleView:label];

'Programing' 카테고리의 다른 글

Spring 트랜잭션  (0) 2012.10.16
[MYSQL] String int 형변환  (0) 2012.08.27
[iPhone] uitextfield 자리수 제한  (0) 2011.10.28
[iPhone] 이미지 썸네일  (0) 2011.10.19
톰캣 포트추가 및 root 변경  (0) 2011.10.02
Posted by npre
,
반응형

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

    

    if([textField isEqual:_distanceField]) {

        if(range.location > 5){

            UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"경고" message:@"이동거리는 6자리까지만 입력이 가능합니다." delegate:self cancelButtonTitle:@"확인" otherButtonTitles:nil, nil];

            

            [alert show];

            [alert release];

            

            return NO;   

        }

    }

    

    return YES;    

}

'Programing' 카테고리의 다른 글

[MYSQL] String int 형변환  (0) 2012.08.27
[iPhone]네비게이션바 타이틀 색상변경  (0) 2011.11.03
[iPhone] 이미지 썸네일  (0) 2011.10.19
톰캣 포트추가 및 root 변경  (0) 2011.10.02
아이폰 근접센서  (0) 2011.08.24
Posted by npre
,
반응형
-정사각형으로 사진을 CROP 하고, 썸네일 크기에 맞게 리사이즈-
먼저, 출처는 다음 기사입니다.
http://tharindufit.wordpress.com/2010/04/19/how-to-create-iphone-photos-like-thumbs-in-an-iphone-app/ 
 
iPhone 사진앨범의 특징은 가로나 세로가 긴 이미지라 할지라도,
정사각형으로 사진을 CROP 하고, 썸네일 크기에 맞게 리사이즈 시킵니다.
 
위의 기사의 내용을 나름대로 보기 편하게(?) 수정을 했습니다.
 
함수명 - makeThumbnailImage
파라미터 - 원본 이미지, 리사이즈없이 CROP만 할지 여부, 리사이즈할 정사각형 한변의 길이
리턴값 - CROP 및 리사이즈된 이미지
 
- (UIImage*) makeThumbnailImage:(UIImage*)image onlyCrop:(BOOL)bOnlyCrop Size:(float)size
{
 CGRect rcCrop;
 if (image.size.width == image.size.height)
 {
  rcCrop = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
 }
 else if (image.size.width > image.size.height)
 {
  int xGap = (image.size.width - image.size.height)/2;
  rcCrop = CGRectMake(xGap, 0.0, image.size.height, image.size.height);
 }
 else
 {
  int yGap = (image.size.height - image.size.width)/2;
  rcCrop = CGRectMake(0.0, yGap, image.size.width, image.size.width);
 }
 
 CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], rcCrop);
 UIImage* cropImage = [UIImage imageWithCGImage:imageRef];
 CGImageRelease(imageRef);
 if (bOnlyCrop) return cropImage;
 
 NSData* dataCrop = UIImagePNGRepresentation(cropImage);
 UIImage* imgResize = [[UIImage alloc] initWithData:dataCrop];
 
 UIGraphicsBeginImageContext(CGSizeMake(size,size));
 [imgResize drawInRect:CGRectMake(0.0f, 0.0f, size, size)];
 UIImage* imgThumb = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 [imgResize release];
 return imgThumb;
}

위 소스를 참고하시면, 이미지를 CROP 하는 방법이나, 이미지를 RESIZE 하는 방법을 참고하실수 있을겁니다.
 
사족을 붙이자면, 왜 Resize 할지 여부를 따로 분리 시킨 이유는 실제로 사용을 해보면 Resize 루틴에서
많은 CPU 부하가 걸립니다. 그래서 UIImageView 에  contentMode를 UIViewContentModeScaleAspectFit 로 설정해서
자체적으로 리사이즈를 하게 하는 방법이 비동기적으로 괜찮습니다. (물론.. 실제 Resize된 이미지가 아니므로 메모리적인 소비는 있습니다.)

'Programing' 카테고리의 다른 글

[iPhone]네비게이션바 타이틀 색상변경  (0) 2011.11.03
[iPhone] uitextfield 자리수 제한  (0) 2011.10.28
톰캣 포트추가 및 root 변경  (0) 2011.10.02
아이폰 근접센서  (0) 2011.08.24
[iPhone] 만보기 로직  (0) 2011.06.27
Posted by npre
,

아이폰 근접센서

Programing 2011. 8. 24. 10:26
반응형
UIDevice *device = [UIDevice currentDevice];

활성화
device.proximityMonitoringEnabled = YES; 

비활성화
device.proximityMonitoringEnabled = NO;

현재 활성화 상태 (BOOL)
device.proximityState

'Programing' 카테고리의 다른 글

[iPhone] 이미지 썸네일  (0) 2011.10.19
톰캣 포트추가 및 root 변경  (0) 2011.10.02
[iPhone] 만보기 로직  (0) 2011.06.27
[iPhone] Tabbar Custom  (0) 2011.06.23
[iPhone] activity indicator 바로뜨게하기  (0) 2011.02.07
Posted by npre
,
반응형

-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{

x = acceleration.x;

y = acceleration.y;

z = acceleration.z;


float dot = (x1 * x) + (py * y) + (z1 * z);

    float a = ABS(sqrt(x1 * x1 + py * py + z1 * z1));

    float b = ABS(sqrt(x * x + y * y + z * z));

    

    dot /= (a * b);



    if (dot<0.8) // bounce

    {

        if (!isChange)

        {

            isChange = YES;


            

_walkCnt  = _walkCnt+1;

            // count increases and all work done here

        } else {

            isChange = NO;


        }


    }

x1 = x;

py = y;

z1 = z;

}

'Programing' 카테고리의 다른 글

톰캣 포트추가 및 root 변경  (0) 2011.10.02
아이폰 근접센서  (0) 2011.08.24
[iPhone] Tabbar Custom  (0) 2011.06.23
[iPhone] activity indicator 바로뜨게하기  (0) 2011.02.07
sqlite auto increment  (0) 2010.11.01
Posted by npre
,

[iPhone] Tabbar Custom

Programing 2011. 6. 23. 14:17
반응형
아이폰 커스텀 탭바

http://www.rumexit.co.uk/2010/07/how-to-customise-the-tab-bar-uitabbar-in-an-iphone-application-part-1-of-2/ 

'Programing' 카테고리의 다른 글

아이폰 근접센서  (0) 2011.08.24
[iPhone] 만보기 로직  (0) 2011.06.27
[iPhone] activity indicator 바로뜨게하기  (0) 2011.02.07
sqlite auto increment  (0) 2010.11.01
Objective C Sqlite like Binding  (0) 2010.10.31
Posted by npre
,
반응형
activiy indicator를 설정하는경우
인디케이터가 바로 노출이 안되는 상황이 발생한다.
약간의 꼼수(?)로 해결을 하였는데,



// 이 함수로 명령을 내린다
-(IBAction)onSrch{
[self startIndicator];
[self performSelector:@selector(onSrchAfter) withObject:nil afterDelay:0.1f];
}


// 빈 함수로 실제 코드가 있는 함수로 연결시켜준다
-(void)onSrchAfter{

[self realSrch];

}


// 실제 구현 함수
-(void)realSrch{

}

어떤 영향을 미치는지는 모르겠다만,,

이런식으로 함수를 하나더 건너뛰게하니 원하는대로 바로 인디케이터가 노출이 되었다.

'Programing' 카테고리의 다른 글

[iPhone] 만보기 로직  (0) 2011.06.27
[iPhone] Tabbar Custom  (0) 2011.06.23
sqlite auto increment  (0) 2010.11.01
Objective C Sqlite like Binding  (0) 2010.10.31
[iPhone] 탭바 숨기기  (0) 2010.10.06
Posted by npre
,
반응형

[actionSheet showInView:self.view] 를
 [actionSheet showInView:self.tabBarController.view]로  변경합니다.
Posted by npre
,
반응형

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ }

여기에서 셀이 선택되었을때 스타일 속성을 아래와같이 준다.

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

이 외에도 속성값으로는
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray

등이 있다.

Posted by npre
,