Skip to content

Instantly share code, notes, and snippets.

View tomohisa's full-sized avatar

Tomohisa Takaoka tomohisa

View GitHub Profile
@tomohisa
tomohisa / UIViewController+JTCAddition.h
Created July 30, 2014 10:07
Storyboard by viewController factory method
#import <UIKit/UIKit.h>
@interface UIViewController (JTCAddition)
+(instancetype) viewControllerFromSameNameStoryboard;
+(UINavigationController*) viewControllerFromSameNameStoryboardInNavigationController;
@end
NSMutableAttributedString * mutable = [[NSMutableAttributedString alloc] init];
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.user.name attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:12*TOVConstSizeRate]}]];
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@" " attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:6*TOVConstSizeRate]}]];
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"(@" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]];
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.user.screenName attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:11*TOVConstSizeRate]}]];
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@")\t" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]];
[mutable appendAt
-(BOOL)isFirstResponderRecursive{
if (self.isFirstResponder) {
return YES;
}
for (UIView * sub in self.subviews) {
if ([sub isFirstResponderRecursive]) {
return YES;
}
}
return NO;
@tomohisa
tomohisa / SpeechReading.m
Created November 26, 2013 16:25
short sample for AVSpeechSynthesizer voice reading feature for iOS 7
// 読み上げオブジェクト
AVSpeechSynthesizer * synthesizer = [[AVSpeechSynthesizer alloc] init];
// 読み上げる内容
AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc] initWithString:NSLocalizedString(@"Welcome to Tweet Overview ", nil)];
// 読み上げる言語の設定
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ja-JP"];
utterance.pitchMultiplier = 1.0;
// 読み上げる
[synthesizer speakUtterance:utterance];
@interface ALAssetsLibrary (JTCCommon)
-(ALAsset*) getSyncAssetFromURL:(NSURL*)url;
-(UIImage*) getSyncFullScreenImageFromURL:(NSURL*)url;
-(UIImage*) getSyncFullResolutionImageFromURL:(NSURL*)url;
-(UIImage*) getSyncThumbnailImageFromURL:(NSURL*)url;
-(UIImage*) getSyncAspectThumbnailImageFromURL:(NSURL*)url;
@end
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:domain]];
[client registerHTTPOperationClass:[AFHTTPRequestOperation class]];
NSMutableDictionary* dicParam = [parameters mutableCopy];
NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/api/path" parameters:dicParam];
[request setTimeoutInterval:20];
AFHTTPRequestOperation *operation = [client HTTPRequestOperationWithRequest:request success:^{...} failure:^{...}];
[client enqueueHTTPRequestOperation:operation];
//
// ViewController.m
// TestUIWebView
//
// Created by Tomohisa Takaoka on 11/5/12.
// Copyright (c) 2012 Tomohisa Takaoka. All rights reserved.
//
#import "ViewController.h"
@tomohisa
tomohisa / ViewController.m
Created September 30, 2012 05:19
Change Select Location on TWTweetComposeViewController
-(IBAction) compose:(id)sender{
TWTweetComposeViewController *tweet = [[TWTweetComposeViewController alloc] init];
[tweet setInitialText:[@" #test"]];
int64_t delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self searchSubviewRecursive:[[UIApplication sharedApplication] keyWindow]];
});
[[TOVAppDelegate sharedDelegate].viewController presentModalViewController:tweet animated:YES];
}
@tomohisa
tomohisa / ViewController.m
Last active October 10, 2015 22:27
Free View at Memory warning
- (void)didReceiveMemoryWarning {
if([self isViewLoaded] && [self.view window] == nil) {
[photoMap removeAllObjects];
self.view = nil;
self.photoImageView = nil;
}
}