{"id":7533,"date":"2016-08-15T08:43:08","date_gmt":"2016-08-14T23:43:08","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=7533"},"modified":"2017-09-29T18:23:39","modified_gmt":"2017-09-29T09:23:39","slug":"delphi-ios%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%a7%e3%83%8d%e3%82%a4%e3%83%86%e3%82%a3%e3%83%96%e3%82%b3%e3%83%b3%e3%83%88%e3%83%ad%e3%83%bc%e3%83%ab%e3%81%ae","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=7533","title":{"rendered":"Delphi iOS\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u753b\u50cf\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<p>FireMonkey\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306f\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>Delphi iOS\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u753b\u50cf\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b<br \/>\n\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306eUIImageView\u3092\u30e9\u30c3\u30d7\u3057\u305f\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>UIImageView\u3082\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u305f\u3081\u3001\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u753b\u50cf\u3092\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u4f7f\u7528\u4f8b<\/h2>\n<pre><code>FUIImageView := FMX.iOS.UIImageView.TUIImageView.Create(Layout1);\nFUIImageView.ImageWrapMode := TImageWrapMode.Fit;\nFUIImageView.SetBitmap(Bitmap);\n<\/code><\/pre>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<pre><code>unit FMX.iOS.UIImageView;\n\ninterface\n\nuses\n  iOSapi.UIKit, iOSapi.CoreGraphics,\n  System.Classes, System.Types, FMX.Graphics,\n  FMX.Layouts, FMX.Forms, FMX.Objects;\n\ntype\n  TUIImageView = class\n  private\n    FUIImageView: iOSapi.UIKit.UIImageView;\n    FLayout: TLayout;\n    FImageWrapMode: TImageWrapMode;\n    procedure SetImageWrapMode(const Value: TImageWrapMode);\n    function GetForm: TCustomForm;\n    function GetLayoutRect: TRect;\n    function getFrame: CGRect;\n  public\n    constructor Create(const ALayout: TLayout);\n    destructor Destroy; override;\n    procedure SetBitmap(const ABitmap: TBitmap);\n    procedure Resize;\n    property ImageWrapMode: TImageWrapMode read FImageWrapMode\n      write SetImageWrapMode;\n    property frame: CGRect read getFrame;\n    property ImageView: iOSapi.UIKit.UIImageView read FUIImageView;\n\n  end;\n\nimplementation\n\nuses\n\n  Macapi.Helpers, FMX.Helpers.iOS, iOSapi.Foundation, FMX.Platform.iOS,\n\n  System.SysUtils, FMX.Types;\n\n{ TUIImageView }\n\nconstructor TUIImageView.Create(const ALayout: TLayout);\nvar\n  AForm: TCustomForm;\nbegin\n  FLayout := ALayout;\n\n  FUIImageView := iOSapi.UIKit.TUIImageView.Wrap\n    (iOSapi.UIKit.TUIImageView.Alloc.init);\n  FUIImageView.retain;\n  Resize;\n\n  AForm := GetForm;\n  if AForm &lt;&gt; nil then\n    WindowHandleToPlatform(AForm.Handle).View.addSubview(FUIImageView);\n\n  Self.ImageWrapMode := TImageWrapMode.Stretch;\nend;\n\ndestructor TUIImageView.Destroy;\nbegin\n  if FUIImageView &lt;&gt; nil then\n  begin\n    FUIImageView.removeFromSuperview;\n    FUIImageView.release;\n    FUIImageView := nil;\n  end;\n\n  inherited;\nend;\n\nfunction TUIImageView.GetForm: TCustomForm;\nvar\n  Parent: TFmxObject;\nbegin\n  Parent := FLayout.Parent;\n\n  while True do\n  begin\n    if Parent = nil then\n      Exit(nil);\n    if Parent is TForm then\n      Exit(Parent as TForm);\n    Parent := Parent.Parent;\n  end;\nend;\n\nfunction TUIImageView.getFrame: CGRect;\nbegin\n  Result := FUIImageView.frame;\nend;\n\nfunction TUIImageView.GetLayoutRect: TRect;\nvar\n  ATopLeft, ABottomRight: TPoint;\nbegin\n  if FLayout = nil then\n  begin\n    Log.d('Layout = nil');\n    Exit(Rect(0, 0, 0, 0));\n  end;\n\n  ATopLeft := FLayout.LocalToAbsolute(PointF(0, 0)).Truncate;\n  ABottomRight := ATopLeft.Add(PointF(FLayout.width, FLayout.height).Truncate);\n  Result := System.Classes.Rect(ATopLeft, ABottomRight);\nend;\n\nprocedure TUIImageView.Resize;\nbegin\n  FUIImageView.setFrame(Macapi.Helpers.RectToNSRect(GetLayoutRect));\nend;\n\nprocedure TUIImageView.SetBitmap(const ABitmap: TBitmap);\nvar\n  Image: UIImage;\n  AutoreleasePool: NSAutoreleasePool;\nbegin\n  AutoreleasePool := TNSAutoreleasePool.Create;\n  try\n    Image := FMX.Helpers.iOS.BitmapToUIImage(ABitmap);\n    FUIImageView.setImage(Image);\n  finally\n    AutoreleasePool.release\n  end;\nend;\n\nprocedure TUIImageView.SetImageWrapMode(const Value: TImageWrapMode);\nbegin\n  FImageWrapMode := Value;\n\n  case Value of\n    TImageWrapMode.Fit: \/\/ \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u56db\u89d2\u5f62\u306b\u3061\u3087\u3046\u3069\u5408\u3046\u3088\u3046\u306b\u8abf\u6574\u3057\u307e\u3059\uff08\u753b\u50cf\u306e\u6bd4\u7387\u306f\u4fdd\u305f\u308c\u307e\u3059\uff09\u3002\n      FUIImageView.setContentMode(UIViewContentModeScaleAspectFit);\n    TImageWrapMode.Stretch: \/\/ \u753b\u50cf\u3092\u5f15\u304d\u4f38\u3070\u3057\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u56db\u89d2\u5f62\u5168\u4f53\u3092\u57cb\u3081\u307e\u3059\u3002\n      FUIImageView.setContentMode(UIViewContentModeScaleToFill);\n    TImageWrapMode.Original: \/\/ \u753b\u50cf\u3092\u5143\u306e\u30b5\u30a4\u30ba\u3067\u8868\u793a\u3057\u307e\u3059\u3002\n      FUIImageView.setContentMode(UIViewContentModeTopLeft);\n    TImageWrapMode.Center: \/\/ \u753b\u50cf\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u56db\u89d2\u5f62\u306e\u4e2d\u592e\u306b\u8868\u793a\u3057\u307e\u3059\u3002\n      FUIImageView.setContentMode(UIViewContentModeCenter);\n    TImageWrapMode.Tile: \/\/ \u753b\u50cf\u3092\u6577\u304d\u8a70\u3081\u3066\uff08\u753b\u50cf\u306e\u6570\u3092\u5897\u3084\u3057\u3066\uff09\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u56db\u89d2\u5f62\u5168\u4f53\u3092\u8986\u3044\u307e\u3059\u3002\n      raise System.SysUtils.ENotImplemented.Create('TImageWrapMode.Tile');\n  end;\nend;\n\nend.\n<\/code><\/pre>\n<h2>\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n<p>TWebBrowser\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306f\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u305f\u3081\u3001\u305d\u306e\u4e0a\u306b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u914d\u7f6e\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u3001TWebBrowser\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306bTUIImageView\u3092\u914d\u7f6e\u3057\u3066\u3001\u753b\u50cf\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u4f8b\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50-300x169.png\" alt=\"Simulator Screen Shot 2016.06.20 0.30.50\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-7537\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png?w=568&amp;ssl=1 568w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u30d5\u30a9\u30fc\u30e0\u306bTWebBrowser\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3068TLayout\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002<br \/>\nTLayout\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306fTUIImageView\u306e\u914d\u7f6e\u5834\u6240\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView01-300x228.png\" alt=\"TUIImageView01\" width=\"300\" height=\"228\" class=\"alignnone size-medium wp-image-7534\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView01.png?resize=300%2C228&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView01.png?w=653&amp;ssl=1 653w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView02.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView02.png\" alt=\"TUIImageView02\" width=\"207\" height=\"122\" class=\"alignnone size-medium wp-image-7535\" \/><\/a><\/p>\n<p>\u30e1\u30cb\u30e5\u30fc\u306e\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u2192\u300c\u30ea\u30bd\u30fc\u30b9\u3068\u753b\u50cf\u300d\u3092\u9078\u629e\u3057\u3001\u8868\u793a\u3059\u308b\u753b\u50cf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView03.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView03-300x169.png\" alt=\"TUIImageView03\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-7536\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView03.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/TUIImageView03.png?w=634&amp;ssl=1 634w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4eca\u56de\u4f7f\u7528\u3057\u305f\u753b\u50cf\u306f\u6b21\u306e\u753b\u50cf\u3067\u3059\u3002<\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/sample.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/sample.png\" alt=\"sample\" width=\"294\" height=\"95\" class=\"alignnone size-full wp-image-7538\" \/><\/a><\/p>\n<p>\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u3080\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><code>function GetImage: TBitmap;\nvar\n  RS: TResourceStream;\nbegin\n  Result := TBitmap.Create;\n  RS := TResourceStream.Create(HInstance, 'PngImage_1', RT_RCDATA);\n  try\n    Result.LoadFromStream(RS);\n  finally\n    RS.Free;\n  end;\nend;\n<\/code><\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u306bprivate\u5909\u6570\u306bTUIImageView\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><code>type\n  TForm1 = class(TForm)\n    WebBrowser1: TWebBrowser;\n    Layout1: TLayout;\n    procedure FormCreate(Sender: TObject);\n  private\n    { private \u5ba3\u8a00 }\n    FUIImageView: TUIImageView;\n  public\n    { public \u5ba3\u8a00 }\n  end;\n<\/code><\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u306eOnCreate\u30a4\u30d9\u30f3\u30c8\u3067\u3001TWebBrowser\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306bURL\u3092\u6307\u5b9a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<pre><code>procedure TForm1.FormCreate(Sender: TObject);\nbegin\n  WebBrowser1.Navigate('http:\/\/www.gesource.jp\/weblog\/');\nend;\n<\/code><\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u306eOnCreate\u30a4\u30d9\u30f3\u30c8\u306bTUIImageView\u3092\u4f5c\u6210\u3059\u308b\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><code>uses\n  FMX.Objects;\n\nprocedure TForm1.FormCreate(Sender: TObject);\nvar\n  Bitmap: TBitmap;\nbegin\n  WebBrowser1.Navigate('http:\/\/www.gesource.jp\/weblog\/');\n\n  FUIImageView := FMX.iOS.UIImageView.TUIImageView.Create(Layout1);\n  FUIImageView.ImageWrapMode := TImageWrapMode.Fit;\n\n  Bitmap := GetImage;\n  try\n    FUIImageView.SetBitmap(Bitmap);\n  finally\n    Bitmap.Free;\n  end;\nend;\n<\/code><\/pre>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u4e0a\u306b\u753b\u50cf\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50-300x169.png\" alt=\"Simulator Screen Shot 2016.06.20 0.30.50\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-7537\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2016\/06\/Simulator-Screen-Shot-2016.06.20-0.30.50.png?w=568&amp;ssl=1 568w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>FireMonkey\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306f\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002 Delphi iOS\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u753b\u50cf\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b \u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306eUIImageV &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=7533\" class=\"more-link\">Continue reading &lsquo;Delphi iOS\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u4e0a\u306b\u753b\u50cf\u3092\u8868\u793a\u3059\u308b&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[162,164,156,118,131],"class_list":["post-7533","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-delphi-10-seattle","tag-delphi-10-1-berlin","tag-delphi","tag-firemonkey","tag-ios"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/7533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7533"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/7533\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}