{"action":"opened","issue":{"url":"https://api.github.com/repos/masashi-sutou/devTips/issues/17","labels_url":"https://api.github.com/repos/masashi-sutou/devTips/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/masashi-sutou/devTips/issues/17/comments","events_url":"https://api.github.com/repos/masashi-sutou/devTips/issues/17/events","html_url":"https://github.com/masashi-sutou/devTips/issues/17","id":115497544,"number":17,"title":"UILabelで自動改行","user":{"login":"masashi-sutou","id":6649643,"avatar_url":"https://avatars.githubusercontent.com/u/6649643?v=3","gravatar_id":"","url":"https://api.github.com/users/masashi-sutou","html_url":"https://github.com/masashi-sutou","followers_url":"https://api.github.com/users/masashi-sutou/followers","following_url":"https://api.github.com/users/masashi-sutou/following{/other_user}","gists_url":"https://api.github.com/users/masashi-sutou/gists{/gist_id}","starred_url":"https://api.github.com/users/masashi-sutou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masashi-sutou/subscriptions","organizations_url":"https://api.github.com/users/masashi-sutou/orgs","repos_url":"https://api.github.com/users/masashi-sutou/repos","events_url":"https://api.github.com/users/masashi-sutou/events{/privacy}","received_events_url":"https://api.github.com/users/masashi-sutou/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/masashi-sutou/devTips/labels/%E8%A8%80%E8%AA%9E","name":"言語","color":"5319e7"},{"url":"https://api.github.com/repos/masashi-sutou/devTips/labels/%E9%96%8B%E7%99%BA%E6%89%8B%E6%B3%95","name":"開発手法","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"masashi-sutou","id":6649643,"avatar_url":"https://avatars.githubusercontent.com/u/6649643?v=3","gravatar_id":"","url":"https://api.github.com/users/masashi-sutou","html_url":"https://github.com/masashi-sutou","followers_url":"https://api.github.com/users/masashi-sutou/followers","following_url":"https://api.github.com/users/masashi-sutou/following{/other_user}","gists_url":"https://api.github.com/users/masashi-sutou/gists{/gist_id}","starred_url":"https://api.github.com/users/masashi-sutou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masashi-sutou/subscriptions","organizations_url":"https://api.github.com/users/masashi-sutou/orgs","repos_url":"https://api.github.com/users/masashi-sutou/repos","events_url":"https://api.github.com/users/masashi-sutou/events{/privacy}","received_events_url":"https://api.github.com/users/masashi-sutou/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-11-06T12:41:31Z","updated_at":"2015-11-06T12:41:31Z","closed_at":null,"body":"## Tipsの内容\r\n- 長い文字列を任意の幅で自動的に改行する方法\r\n\r\n## 何が便利なのか\r\n- テーブルセルの高さを内容の高さによって可変にする際に使用する\r\n- 結構な時間がかかったのでログを残す\r\n\r\n## ソース\r\n\r\n- UIILabelの文字列の高さに応じてセルの高さを取得する\r\n```\r\n+ (CGFloat)heightWithMaterial:(DetailedMaterial *)material width:(CGFloat)width\r\n{\r\n    UILabel *label = [[[UILabel alloc] init] autorelease];\r\n    [label setFont:[self.class fontForMaterialTitle]];\r\n    [label setText:material.materialTitle];\r\n    [label setLineBreakMode:NSLineBreakByWordWrapping];\r\n    [label setNumberOfLines:0];\r\n    [label setFrame:CGRectMake(0,0,width - (SideMargin + 50 + Space),label.size.height)];\r\n    [label sizeToFit];\r\n    \r\n    UIImage *shelveButtonImage = [UIImage imageNamed:@\"record_button_shelf_normal\"];\r\n    \r\n    return MAX(TopMargin + label.size.height + Space + shelveButtonImage.size.height + Space, 90);\r\n}\r\n``` \r\n## 参考URL\r\n- http://buchi.hatenablog.com/entry/2014/09/11/135036"}}