Skip to content

Instantly share code, notes, and snippets.

View tatsuro-ueda's full-sized avatar

Tatsuro Ueda tatsuro-ueda

View GitHub Profile
@tatsuro-ueda
tatsuro-ueda / 2つのセグエを連続して実行するには.md
Created August 12, 2012 05:11
【セグエ】2つのセグエを連続して実行するには

I tried to move segue continually, but I failed, too.

So I tried to set interval between first segue and second segue for one second.

ss

This works well ! When you push button in red window, green window appears, and after it, blue window appears automatically.

- (void)viewDidLoad
{
@tatsuro-ueda
tatsuro-ueda / 他のビューに移っても値を保持したい.md
Created August 12, 2012 05:09
他のビューに移っても値を保持したい

There is View-independent value keeping tool. You can use:

[[NSUserDefaults standardUserDefaults]setObject:<#(id)#> forKey:<#(NSString *)#>]

For example, you inputs strings or datas in A view, you can store them in above variables. And then, in B view, you can use them by below code:

 [[NSUserDefaults standardUserDefaults]objectOrKey:<#(NSString *)#>]

These are a example of NSUserdefaults data using:

@tatsuro-ueda
tatsuro-ueda / CAレイヤーのドロップシャドウを本体が大きくなる時に一緒に大きくしたい.md
Created August 12, 2012 05:07
【アニメーション】CAレイヤーのドロップシャドウを本体が大きくなる時に一緒に大きくしたい

##Animating a CALayer shadowpath

At first, small square with drop shadow.

ss

When button pushed, square and shadow grow bigger together.

ss

@tatsuro-ueda
tatsuro-ueda / 文字コードの不一致により正規表現のマッチングが失敗するときは.md
Created August 11, 2012 17:00
【文字コード】文字コードの不一致により正規表現のマッチングが失敗するときは

I also have encountered the regular expression exception, too. In my case, the problem was Character Encoding. So that I wrote a code to go well with several character encoding. Maybe this code help you.

+ (NSString *)encodedStringWithContentsOfURL:(NSURL *)url
{
    // Get the web page HTML
    NSData *data = [NSData dataWithContentsOfURL:url];
    
	// response
	int enc_arr[] = {

NSUTF8StringEncoding, // UTF-8

@tatsuro-ueda
tatsuro-ueda / ローカル時間の変換をするには.md
Created August 11, 2012 11:26
ローカル時間の変換をするには

##Convert GMT to IST in iOS

The code below convert GMT to IST.

NSString *inDateStr = @"2000/01/02 03:04:05";
NSString *s = @"yyyy/MM/dd HH:mm:ss";

// about input date(GMT)

NSDateFormatter *inDateFormatter = [[NSDateFormatter alloc] init];

@tatsuro-ueda
tatsuro-ueda / ViewControllerのつなげ忘れ.md
Created August 11, 2012 11:24
【IB】ViewControllerのつなげ忘れ

Have you wired all storyboard object to proper ViewController ? I often forget wiring delegate =)

ss

@tatsuro-ueda
tatsuro-ueda / 【テーブル】【セグエ】テーブルセルからセグエで情報を渡しながら別のビューへ遷移する.md
Created August 11, 2012 11:21
【テーブル】【セグエ】テーブルセルからセグエで情報を渡しながら別のビューへ遷移する

You can wire from TableViewController to other view.

ss

For example, at first, you can set TableViewCell as below:

ss

When tap the cell, the view with the number of tapped cell.

@tatsuro-ueda
tatsuro-ueda / Setting-progress-of-ProgressView-while-parsing-XML
Created August 11, 2012 11:14
【XMLパーサ】【スレッド】XMLのパース進捗状況をプログレスバーで表示するには
##Setting progress of ProgressView while parsing XML
First, count the number of lines.
NSError *error = nil;
NSString *xmlFileString = [NSString stringWithContentsOfURL:url
encoding:NSUTF8StringEncoding error:&error];
_totalLines = [xmlFileString componentsSeparatedByString:@"\n"].count;
Then, catch the progress in delegate method block. For example:
@tatsuro-ueda
tatsuro-ueda / using-UIDatePicker-on-static-cell.md
Created August 11, 2012 11:07
【テーブル】【static cells】static cellsのテーブルにUIDatePickerを置くには

##using UIDatePicker on static cell

Just one row code solved the Problem. Stunner's advice is very helpful for this final answer.

- (IBAction)inputDate:(id)sender {
    self.label.text = [NSString stringWithFormat:@"%@", self.datePicker.date];
    [self.tableView reloadData]; // <- add this row !
}

screenshot

@tatsuro-ueda
tatsuro-ueda / Create-Custom-button-like-human-Hand.md
Created August 11, 2012 11:05
カスタムな当たり判定を設定するには

##Create Custom button like human Hand

I think at first you have to make polygon which fit to your image. And then you can use touchesBegan:withEvent: to get the coordinate of touch point and judge whether the point is inside of polygon or not.

Here is similar question like yours.

http://stackoverflow.com/questions/8450967/how-to-get-particular-touch-area

I think this is a little difficult work, so maybe you would better use cocos2d library which have collision judgement function.