본문 바로가기

분류 전체보기

아이폰에서 유튜브 플레이하는 코드 - (void)embedYouTube:(NSString*)url frame:(CGRect)frame { NSString* embedHTML = @"\ \ \ "; NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height]; if(videoView == nil) { videoView = [[UIWebView alloc] initWithFrame:frame]; [self.view addSubview:videoView]; } [videoView loadHTMLString:html baseURL:nil]; } 더보기
UIWebView에서 현재의 웹주소와 웹문서 제목 가져오기 - (void)webViewDidFinishLoad:(UIWebView *)webView { // 웹주소 NSString *addr = [[webView.request URL] absoluteString]; // 웹문서 제목 NSString* title = [webView stringByEvaluatingJavaScriptFromString: @"document.title"]; } 더보기
아이폰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).. 더보기