Skip to content

Instantly share code, notes, and snippets.

View tomohisa's full-sized avatar

Tomohisa Takaoka tomohisa

View GitHub Profile
@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;
}
}
-(void)test{
__weak MyViewController* wself=self;
dispatch_async(dispatch_get_main_queue(),^{
// Error on llvm 4.0
wself->_mycount = 2;
});
}
@tomohisa
tomohisa / ViewController.m
Created July 25, 2012 01:09
Add ChildViewController Help Method.
#pragma mark - help functions
-(void) addChildViewControllerWithIdentifier:(NSString*)identifier inArea:(CGRect)rect closeOtherChildView:(BOOL)isClose toView:(UIView*) toView{
if (isClose) {
for (UIViewController* vc in self.childViewControllers) {
[vc.view removeFromSuperview];
[vc removeFromParentViewController];
}
}
@tomohisa
tomohisa / NSArray+IndexHelper.h
Created July 8, 2012 06:53
Using ObjectAtIndex safely with this method.
//
// NSArray+IndexHelper.h
// C_POS
//
// Created by Tomohisa Takaoka on 6/14/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@tomohisa
tomohisa / gist:2897676
Created June 8, 2012 19:20
Add and Remove ChildViewController
// add child view
UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
[self addChildViewController:controller];
controller.view.frame = CGRectMake(0, 44, 320, 320);
[self.view addSubview:controller.view];
[controller didMoveToParentViewController:self];
// remove child view
UIViewController *vc = [self.childViewControllers lastObject];
[vc.view removeFromSuperview];