-(void)twitterWithTitle:(NSString*)title msg:(NSString*)msg image:(UIImage*)image url:(NSURL*)url viewController:(UIViewController*)cont{ TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init]; if(twitter==nil){ NSString * text = @""; text = @"트위터공유를 이용하시려면, iOS 5.0 이상으로 업그레이드 하여주세요."; [UIAlertView Alert:@"Twitter" :text]; return; } [twitter setInitialText:msg]; if(image!=nil) [twitter addImage:image]; if(url!=nil) [twitter addURL:url]; [cont presentModalViewController:twitter animated:YES]; [twitter setCompletionHandler:^(TWTweetComposeViewControllerResult result){ NSString *title = title; NSString *message; if (result == TWTweetComposeViewControllerResultCancelled) { message = @"Twitter Status upload was canceled"; } else { message = @"트위터 게시에 성공하였습니다"; [[[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] show]; } [cont dismissModalViewControllerAnimated:YES]; }]; }
빌드페이즈에서 트위터 프레임워크를 추가하자.
'Objective-C' 카테고리의 다른 글
[iOS] URL스키마가 아닌 mail viewcontroll를 사용하여 메일보내기 (0) | 2012.08.28 |
---|---|
[Sqlite3] 멀티스레드에서 정상작동되도록 설정하기 (0) | 2012.07.10 |
[Debug] gdb를 이용한 객체 내용보기 (0) | 2012.06.28 |
[iOS] GCD를 이용한 백그라운드 작업 (0) | 2012.06.27 |
[iOS] 블럭코딩시 블럭 밖 외부 변수 사용 (0) | 2012.06.11 |