NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; NSNumber* candidateNumber; NSString* candidateString = [textField.text stringByReplacingCharactersInRange:range withString:string]; range = NSMakeRange(0, [candidateString length]); [numberFormatter getObjectValue:&candidateNumber forString:candidateString range:..
#import 콜백함수로 등록 // Registers the audio route change listener callback function AudioSessionAddPropertyListener ( kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self ); 콜백함수 void audioRouteChangeListenerCallback ( void *inUserData, AudioSessionPropertyID inPropertyID, UInt32 inPropertyValueSize, const void *inPropertyValue ) { CFDictionaryRef routeChangeDictionary = in..
파일경로는 간단하게.. [[NSBundle mainBundle] pathForResource:@"aps" ofType:@"cer"]; 위 경로를 받아서 아래와 같이 검사 BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:somePath]; ex> NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath]; if (fileExists) { NSLog(@"Exist"); }else { NSLog(@"Not Exis..
웹 소스를 파싱하다 보면 javascript로 해당 페이지를 꾸밀때 함수가 뒤늦게 호출되어 미처 값을 가져 오지 못할때 webViewDidFinishLoad: 델리게이트 함수를 이용해 로딩이 끝났을때 NSString *html = [yourWebView stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"]; 를 통해 해당 페이지 소스를 가져올 수 있음! ps. [NSString stringWithContentsOfURL: encoding: error:]; 이걸로는 그냥 웹페이지 '소스 보기' 한것과 같은 결과
아이폰은 한글이 3바이트 라서.. NSInteger convertedLength = [targetStr lengthOfBytesUsingEncoding:(0x80000000 + 0x0422)]; //EUC-KR 식으로 길이 계산 char *converted = [targetStr cStringUsingEncoding:(0x80000000 + 0x0422)]; //EUC-KR 형식으로 인코딩된 char* NSLog(@"%d 글자 입력", convertedLength); if (convertedLength > 40) { // 한글은 2바이트로 계산한 Byte 길이 체크 NSData *data = [NSData dataWithBytes:target length:40]; // 딱 거기까지 잘라오기 NSStrin..
투명하게 만들면 Flexible 아이템을 사용해서 정렬 편하게 할수 있어서... http://stackoverflow.com/questions/2468831/couldnt-uitoolbar-be-transparent http://blog.blackwhale.at/2010/07/transparent-uitoolbar/ @interface TransparentToolbar : UIToolbar @end @implementation TransparentToolbar // Override draw rect to avoid // background coloring - (void)drawRect:(CGRect)rect { // do nothing in here } // Set properties to make ba..
NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:@"340000"]; NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [currencyFormatter setCurrencySymbol:@""];//\ 표시 제거 [target setText:[NSString stringWithFormat:@"%@원", [currencyFormatter stringFromNumber:someAmount]]];
델리게이트 설정 후 - (void)webViewDidFinishLoad:(UIWebView *)aWebView { CGRect frame = aWebView.frame; frame.size.height = 1; aWebView.frame = frame; CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero]; frame.size = fittingSize; aWebView.frame = frame; NSLog(@"size: %f, %f", fittingSize.width, fittingSize.height); } ps. 이미지 같은거 불러올때 걸릴 경우가 있어서 - (void)webViewDidStartLoad:(UIWebView *)webView { webVi..
//일수 구하기 NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *comp = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit) fromDate:self.viewDate]; [comp setDay:0]; [comp setMonth:comp.month+1]; int days = [[gregorian components:NSDayCalendarUnit fromDate:[gregorian dateFromComponents:comp]] day]; NSLog(@"day = %d", days); [gre..
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectory = [paths objectAtIndex:0]; // Documents Directory NSString* FilePath = [documentsDirectory stringByAppendingPathComponent:@"FileName"]; // FileName
CGRect frame = _textView.frame; frame.size.height = _textView.contentSize.height; _textView.frame = frame; Edit: sizeThatFits returns the size but does not actually resize the component. I'm not sure if that's what you want, or if [textView sizeToFit] is more what you were looking for. In either case, I do not know if it will perfectly fit the content like you want, but it's the first thing to t..
#if __IPHONE_3_2 && __IPHONE_3_2
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"URL"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
0x80000000 + kCFStringEncodingDOSKorean NSURLConnection 을 사용해 return 받을때 서버가 UTF-8 임에도 EUC-KR로 줄때 -_-. NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *str = [[NSString alloc] initWithData:returnData encoding:0x80000000 + kCFStringEncodingDOSKorean];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"22", @"published",@"33",@"key",nil]; NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"23", @"published",@"34",@"key",nil]; NSDictionary *dic3 = [NSDictionary dictionaryWithObjectsAndKeys:@"22", @"published",@"35",@"key",nil]; NSDictionary *dic4 = [NSDictionary dictionaryWithObjectsAndKeys:@"24", @"published",@"36",..
#pragma mark - #pragma mark UIWebViewDelegate -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { //YES 면 링크 가능(처음에 불러올때도 인식하니 주의) NO면 다른페이지 안됨 ㅋㅋ return !whenLoaded; } - (void)webViewDidStartLoad:(UIWebView *)webView { // starting the load, show the activity indicator in the status bar [UIApplication sha..
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - Notification 받기 [nc addObserver:self selector:@selector(myMethod:) name:@"myNotiName" object:nil]; - Notification 날리기 [nc postNotificationName:@"myNotiName" object:self userInfo:nil]; - Notification 해제 [nc removeObserver:self name:@"myNotiName" object:nil]; 메소드 선언은 다음과 같이 -(void)myMethod:(NSNotification *)noti{ NSString *stringVa..
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *date = [NSDate date]; NSDateComponents *hourDate = [gregorian components:kCFCalendarUnitHour fromDate:date]; NSDateComponents *minuteDate = [gregorian components:kCFCalendarUnitMinute fromDate:date]; NSDateComponents *secondDate = [gregorian components:kCFCalendarUnitSecond fromDate:date]; int ho..
//장면 전환 효과들 중에 옆으로 밀려서 나오고 스르륵 하고 그런효과들.. 책장 넘기는것 같은 효과 같은건 UIAnimationTransition #import CATransition *transition; // First create a CATransition object to describe the transition transition = [CATransition animation]; // Animate over 3/4 of a second transition.duration = 0.75; // using the ease in/out timing function transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaT..
//웹에서 이미지 불러와서 표시 //http://imgmovie.naver.com/mdi/mi/0490/49008_P51_144449.jpg UIImage *img = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://imgmovie.naver.com/mdi/mi/0490/49008_P51_144449.jpg"]]] retain]; if (img != nil) { // Image was loaded successfully. [myImageView setImage:img]; [myImageView setUserInteractionEnabled:NO]; [img release]; // Release th..
//그냥 바로 html 문자열 보여주기 NSString *htmlString; htmlString = [NSString stringWithFormat:@"%@", @"Test String"]; myWebView.opaque = NO; myWebView.backgroundColor = [UIColor clearColor]; [self.myWebView loadHTMLString:htmlString baseURL:nil]; //웹상 URL을 읽어오려면 [self.myWebView loadRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iphonedevsdk.com/forum/iphone-sdk-development/5573-ca..