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 / Text-views-on-table-view-cells.md
Created August 11, 2012 10:38
【IB】UITextViewをUITableViewに載せるには

You can make it with TextView like below:

ss

ss

You can make this by only IB like below:

ss

@tatsuro-ueda
tatsuro-ueda / YouTube-Video-Api-in-JSON-Format.md
Created August 11, 2012 10:40
【テーブル】【JSON】【AFNetworking】YouTube APIで得たJSONを使ってテーブルを作るには

##YouTube Video Api in JSON Format

Below code parse YouTube JSON to table view.

ss

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;

if (indexPath.row < [[_JSON valueForKeyPath:@"data.items.title"] count]) {

@tatsuro-ueda
tatsuro-ueda / Change-the-position-of-UIBarButtonItem.md
Created August 11, 2012 10:41
【IB】ナビゲーションバー上のUIBarButtonItemの位置を変えるには

##Change the position of UIBarButtonItem

I think present location setting is lick below:

ss

Under this setting the length of left margin is adopted to landscape mode. So you have to set the length of right margin and let the botton put right end of navigation bar.

You would better set the setting as below:

##How to write text with angle on picture in objective c

Below code rotates the label

- (IBAction)rotate:(id)sender {
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(endAnimation)];

@tatsuro-ueda
tatsuro-ueda / Speed-of-segue-between-ViewControllers.md
Created August 11, 2012 10:44
【セグエ】セグエによる遷移のスピードを変えるには

##Speed of segue between ViewControllers

Below code is of custom segue, and you can set duration of transition in code.

- (void)perform 
{
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;
    [UIView transitionFromView:src.view

toView:dst.view

@tatsuro-ueda
tatsuro-ueda / Press-and-hold-to-make-Image-move
Created August 11, 2012 11:03
【performSelector】ボタンを押し続けるとイメージが動き、離すと動きが止まる、には
##Press and hold to make Image move
With below code, you have to push 3 seconds to move _imageView, and then the image begins moving, and when you release the button, the image stops.
![ss](http://farm8.staticflickr.com/7264/7758110866_f2d3a47f04_o.png)
- (IBAction)pushToMove:(id)sender {
[self performSelector:@selector(move) withObject:nil afterDelay:3.0];
}
@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.

@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 / 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 / 【テーブル】【セグエ】テーブルセルからセグエで情報を渡しながら別のビューへ遷移する.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.