{"id":1275,"date":"2016-02-22T12:29:03","date_gmt":"2016-02-22T03:29:03","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=1275"},"modified":"2016-05-14T14:42:53","modified_gmt":"2016-05-14T05:42:53","slug":"tttattributedlabel-peek-and-pop","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2016\/02\/tttattributedlabel-peek-and-pop\/","title":{"rendered":"TTTAttributedLabel \u3067 Peek & Pop \u306b\u5bfe\u5fdc\u3059\u308b (2016\u5e745\u6708\u66f4\u65b0)"},"content":{"rendered":"
TTTAttributedLabel<\/a> \u306f UILabel \u306e\u4ee3\u308f\u308a\u306b\u5229\u7528\u3067\u304d\u308b, \u30ea\u30f3\u30af\u306e\u691c\u51fa\u306a\u3069\u306e\u6a5f\u80fd\u3092\u5099\u3048\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059. \u3053\u306e\u8a18\u4e8b\u3067\u306f TTTAttributedLabel \u3067\u8868\u793a\u3057\u3066\u3044\u308b\u30ea\u30f3\u30af\u3092 iPhone 6s \/ 6s Plus \u3067\u5229\u7528\u3067\u304d\u308b\u00a03D Touch<\/a> \u306e\u6a5f\u80fd\u306e\u4e00\u3064\u3067\u3042\u308b Peek & Pop \u306b\u5bfe\u5fdc\u3055\u305b\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059.<\/p>\n <\/p>\n \u3053\u306e\u8a18\u4e8b\u3067\u306f\u3042\u308b ViewController \u306e subview \u3068\u3057\u3066\u00a0TTTAttributedLabel \u3092\u6301\u3061, \u3053\u306e\u00a0TTTAttributedLabel \u306e\u4e2d\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30ea\u30f3\u30af\u3092 Peek & Pop \u306b\u5bfe\u5fdc\u3055\u305b\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059.<\/p>\n \u52d5\u4f5c\u306e\u30a4\u30e1\u30fc\u30b8 (Tweetbot 4 \u3088\u308a):<\/p>\n <\/a><\/p>\n (\u203bTweetbot 4 \u304c\u00a0TTTAttributedLabel \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093)<\/p>\n TTTAttributedLabel \u3092 subview \u3068\u3057\u3066\u914d\u7f6e\u3055\u305b\u308b\u65b9\u6cd5\u3084,\u00a0TTTAttributedLabel \u3067\u30ea\u30f3\u30af\u3092\u691c\u51fa\u3057\u3066\u8868\u793a\u3059\u308b\u65b9\u6cd5\u306a\u3069\u306f\u3053\u306e\u8a18\u4e8b\u306e\u5bfe\u8c61\u5916\u3067\u3059.<\/p>\n 2016\/5\/14 \u66f4\u65b0: 2016\/5 \u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f 2.0.0<\/a> \u3067 Peek & Pop \u306b\u5bfe\u5fdc\u3059\u308b\u306b\u306f Peek & Pop \u306b\u5bfe\u5fdc\u3059\u308b\u306b\u306f ViewController \u3092 2\u884c\u76ee\u306e 12-14\u884c\u76ee\u306e\u00a0 TTTAttributedLabel \u306f UILabel \u306e\u4ee3\u308f\u308a\u306b\u5229\u7528\u3067\u304d\u308b, \u30ea\u30f3\u30af\u306e\u691c\u51fa\u306a\u3069\u306e\u6a5f\u80fd\u3092\u5099\u3048\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059. \u3053\u306e\u8a18\u4e8b\u3067\u306f TTTAttributedLabel \u3067\u8868\u793a\u3057\u3066\u3044\u308b\u30ea\u30f3\u30af\u3092 iPhone […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[11],"_links":{"self":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1275"}],"collection":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/comments?post=1275"}],"version-history":[{"count":16,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1275\/revisions"}],"predecessor-version":[{"id":1331,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1275\/revisions\/1331"}],"wp:attachment":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/media?parent=1275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/categories?post=1275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/tags?post=1275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u76ee\u6a19<\/h2>\n
TTTAttributedLabel<\/h2>\n
\u73fe\u5728\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u3044\u308b1.13.4 \u306f Peek & Pop \u306b\u5bfe\u5fdc\u3059\u308b\u305f\u3081\u306b\u4fbf\u5229\u306a\u30e1\u30bd\u30c3\u30c9 linkAtPoint<\/code> \u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u305b\u3093.\u00a0c9d9219<\/a> \u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u306e\u3067, \u3053\u308c\u4ee5\u964d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092 Git \u3067\u53d6\u5f97\u3057\u3066\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044.
\n<\/del><\/p>\n-[TTTAttributedLabel linkAtPoint:]<\/code> \u304c\u516c\u958b\u3055\u308c\u307e\u3057\u305f. 2.0.0 \u4ee5\u964d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u7528\u3044\u308b\u3053\u3068\u3067, \u4ee5\u4e0b\u306e\u624b\u9806\u306b\u5f93\u3063\u3066 3D Touch \u5bfe\u5fdc\u3092\u884c\u3048\u307e\u3059.<\/p>\n
viewDidLoad<\/h2>\n
registerForPreviewingWithDelegate:sourceView:<\/code> \u3092\u7528\u3044\u3066, Peek & Pop \u3092\u5229\u7528\u3059\u308b\u30d3\u30e5\u30fc\u3092\u767b\u9332\u3057\u3066\u304a\u304d\u307e\u3059. \u3053\u3053\u3067\u306f UIViewController\u00a0\u306e\u00a0
view<\/code> \u3092\u767b\u9332\u3057\u307e\u3059.<\/p>\n
override func viewDidLoad() {\r\n \/\/ \u7701\u7565\r\n\r\n if traitCollection.forceTouchCapability == .Available {\r\n registerForPreviewingWithDelegate(self, sourceView: view)\r\n }\r\n}<\/pre>\n
UIViewControllerPreviewingDelegate<\/h2>\n
UIViewControllerPreviewingDelegate<\/code> \u306b\u9069\u5408\u3055\u305b\u307e\u3059. \u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059.<\/p>\n
extension ViewController: UIViewControllerPreviewingDelegate {\r\n func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {\r\n let point = previewingContext.sourceView.convertPoint(location, toView: label)\r\n guard label.containslinkAtPoint(point) else { return nil }\r\n guard let link = label.linkAtPoint(point),\r\n url = link.result.URL else { return nil }\r\n \/\/ previewingContext.sourceRect \u3092\u3088\u3057\u306a\u306b\u8a2d\u5b9a\u3059\u308b\r\n let safariViewController = SFSafariViewController(URL: url)\r\n return safariViewController\r\n }\r\n\r\n func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {\r\n \u3000presentViewController(viewControllerToCommit, animated: true, completion: nil)\r\n }\r\n}<\/pre>\n
previewingContext:viewControllerForLocation:<\/code> \u306f Peek \u3059\u308b\u969b\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059.
location<\/code> \u306e\u5834\u6240\u306b\u3042\u308b\u30d3\u30e5\u30fc\u304c Peek \u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u306e\u3067\u3042\u308c\u3070, Peek \u3059\u308b ViewController \u3092\u8fd4\u3057, Peek \u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3042\u308c\u3070
nil<\/code> \u3092\u8fd4\u3057\u307e\u3059.\u00a0\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u306f\u6b21\u306e\u3088\u3046\u306a\u51e6\u7406\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059 (
label<\/code> \u3092 TTTAttributedLabel \u3068\u3057\u307e\u3059):<\/p>\n
\n
label<\/code>\u00a0\u4e0a\u306e\u5ea7\u6a19\u306b\u5909\u63db\u3057\u307e\u3059<\/li>\n
previewingContext:viewControllerForLocation:<\/code> \u3067\u306f\u00a0
previewingContext.sourceRect<\/code> \u306b\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u30d3\u30e5\u30fc\u306e CGRect \u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067, \u6307\u5b9a\u3057\u305f\u00a0CGRect \u306e\u7bc4\u56f2\u4ee5\u5916\u306b\u30d6\u30e9\u30fc\u304c\u304b\u3051\u3089\u308c\u307e\u3059. \u3057\u304b\u3057, \u30ea\u30f3\u30af\u306e\u5f62\u306f\u5fc5\u305a\u3057\u3082\u9577\u65b9\u5f62\u3068\u306f\u9650\u3089\u306a\u3044\u305f\u3081, \u30e9\u30d9\u30eb\u5168\u4f53\u3092 sourceRect \u306b\u8a2d\u5b9a\u3059\u308b\u306a\u3069\u9069\u5f53\u306a\u5bfe\u5fdc\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059.<\/p>\n
previewingContext:viewControllerForLocation:<\/code> \u306f Pop \u3059\u308b\u969b\u306b\u547c\u3070\u308c\u308b\u51e6\u7406\u3067\u3059. \u901a\u5e38\u306f Peek \u6642\u306e ViewController \u3092\u305d\u306e\u307e\u307e\u8868\u793a\u3059\u308b\u306e\u3067,
viewControllerToCommit<\/code> \u3078\u9077\u79fb\u3059\u308b\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059.<\/p>\n
\u53c2\u8003\u8cc7\u6599<\/h2>\n
\n