본문 바로가기

iOS Programming

아이폰sdk에서 내가 만든 delegate로 파라미터 잔송하기 @class C1; @protocol C1Delegate @optional - (void)doC1:(C1 *)c1 param1(NSString *)param1 param2:(int)param2; @end @interface C1 : UIViewController { id delegate; } - (IBAction)doDelegate:(id)sender; @end @implementation C1 - (IBAction)doDelegate:(id)sender { if (self.delegate != NULL && [self.delegate respondsToSelector:@selector(doC1: param1: param2:)]) { [delegate doC1:self param1:@"delegate t.. 더보기
아이폰SDK에서 첨부파일 포함하여 밀티파트 폼포스트로 웹전송하기 @interface WebReguest : NSObject { } - (NSMutableURLRequest *)prepareURLRequest:(NSString *)domain subPage:(NSString *)subPage; - (void)appendBodyData:(NSMutableData *)body fieldName:(NSString *)fieldName text:(NSString *)data; - (void)appendBodyData:(NSMutableData *)body fieldName:(NSString *)fieldName fileName:(NSString *)fileName data:(NSData *)data; - (NSString *)requestURL:(NSMutableURLRequ.. 더보기
경도/위도 좌표로 주소 알아내기 - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error { self.mapAddress = @""; } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { NSString *str = [NSString stringWithFormat:@""]; str = [str stringByAppendingFormat:@"%@", placemark.country]; if([placemark.administrativeArea length] > 0) { str = [str stringByAppendi.. 더보기
아이폰 sdk 로 간단한 트윗 날리기 - (BOOL)sendTwit { NSString *unpw = [[NSString stringWithFormat:@"%@:%@", 아이디, 비밀번호] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *tweet = [NSString stringWithFormat:@"%@", 트윗내용]; tweet = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)tweet, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8 ); NSString *body = [NSString stringWi.. 더보기
Multiline UILabel의 수직 정렬 (Top / Center / Bottom) #import typedef enum VerticalAlignment { VerticalAlignmentTop, VerticalAlignmentMiddle, VerticalAlignmentBottom, VerticalAlignmentFlexible, } VerticalAlignment; @interface LWLabel : UILabel { VerticalAlignment verticalAlignment_; } @property (nonatomic, assign) VerticalAlignment verticalAlignment; - (CGRect)rectForText; @end @implementation LWLabel @synthesize verticalAlignment = verticalAlignme.. 더보기
애니메이션효과로 탭바 숨기고 보이기 - (void) hidetabbar:(BOOL)hide { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.2]; for(UIView *view in self.tabBarController.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { if (!hide) [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)]; else [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.. 더보기
UINavigationBar에 이미지를 배경으로 지정하기 #import @interface LWNavigationBar : UINavigationBar { UIImage*background; } @end @implementation LWNavigationBar - (void)drawRect:(CGRect)rect { if(background == nil) background = [UIImage imageNamed:@"cs1_header.png"]; [background drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } - (void)dealloc { [background release]; [super dealloc]; } @end Interface Builder 에서 N.. 더보기
cocoa touch 에서의 간단한 pdf 핸드링 @interface MMPDFView : UIView { CGPDFDocumentRefpdfDoc; } - (void)loadPDF:(NSURL *)url; - (void)drawPdfPage:(int)page context:(CGContextRef)ctxt area:(CGRect)vrect isZoom:(BOOL)isZoom; @end @implementation MMPDFView - (void)loadPDF:(NSURL *)url { if(pdfDoc != nil) CGPDFDocumentRelease(pdfDoc); pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)url); [self setNeedsDisplay]; } - (void)drawPdfPage:(int).. 더보기
UITableViewCell에 Badge 달기 // // MMTableViewCell.h // // Created by 장영준 on 10. 7. 16.. // Copyright 2010 Wizsoft. All rights reserved. // #import @interface MMBadgeView : UIView { NSUInteger width; NSUInteger badgeNumber; UIFont *font; UITableViewCell *parent; UIColor *badgeColor; UIColor *badgeColorHighlighted; } @property (nonatomic, readonly) NSUInteger width; @property (nonatomic, assign) NSUInteger badgeNumber; @prop.. 더보기
iPhone SDK 4.0에서 기존 프로젝트의 Base SDK missing 문제 해결하기 오늘 iOS 4.0 릴리즈와 함께 Xcode 3.2.3 버전과 함께 iPhone OS 4.0 SDK 버전이 정식 릴리즈 되었습니다. 이번 버전을 다운로드 받아서 설치하면 기존 작업중이던 프로젝트가 Base SDK missing 이라는 에러로 빌드가 안되는 문제 때문에 당황하셨던 분이 적지 않으셨을 듯 합니다. 이를 해결하는 방법은 아래와 같습니다. 1. 기존 프로젝트를 열고 Project Info 창을 엽니다. 2. 아래와 같이 Configuration과 Setting 을 All 로 지정하고 Base SDK를 iPhone OS 4.0으로 지정합니다. (iPhone 3.2로 지정해도 됩니다.) 3. 그리고 아래 부분의 iPhone OS Deployment Target 을 원하는 최소 사양의 버전으로 지정합.. 더보기