Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 10479|回复: 11

lazarus支持iphone了?

[复制链接]

该用户从未签到

发表于 2010-10-27 00:00:43 | 显示全部楼层 |阅读模式






The sample requires a objective-p compiler (fpc 2.5.1 or higher) with cocoaint packages compiled for iPhone
  1. program project1;
  2. {$mode objfpc}{$H+}
  3. {$modeswitch objectivec1}
  4. {$linkframework UIKit}
  5. uses
  6.    iPhoneAll, CGContext, CGGeometry, CFString;
  7. type
  8.    TAppDelegate = objcclass(NSObject)
  9.      procedure applicationDidFinishLaunching(application: UIApplication); message 'applicationDidFinishLaunching:';
  10.    end;
  11.    TMyWindow = objcclass(UIWindow)
  12.    public
  13.      procedure drawRect(c: CGRect); override;
  14.    end;
  15. const
  16.    helloworld = 'Hello world';
  17. // window paint method
  18. procedure TMyWindow.drawRect(c: CGRect);
  19. var
  20.    cg : CGContextRef;
  21. begin
  22.    // getting current context
  23.    cg:=UIGraphicsGetCurrentContext;
  24.    // setting back ground color
  25.    CGContextSetRGBFillColor(cg, 0, 0, 0.5, 1);
  26.    CGContextFillRect(cg, c);
  27.    // rotating up-side down context
  28.    CGContextTranslateCTM(cg, 0, c.size.height);
  29.    CGContextScaleCTM(cg, 1, -1);
  30.    // setting text color
  31.    CGContextSetRGBFillColor(cg, 1, 1, 0, 1);
  32.    CGContextSetRGBStrokeColor(cg, 1, 1, 0, 1);
  33.    // setting font  (must set any)
  34.    CGContextSelectFont(cg, 'Helvetica', 30, kCGEncodingMacRoman);
  35.    // rendering text
  36.    CGContextShowTextAtPoint(cg, 0, c.size.height-50, helloworld, length(helloworld));
  37. end;
  38. var
  39.    mainwindow : TMyWindow;
  40. { TAppDelegate }
  41. procedure TAppDelegate.applicationDidFinishLaunching(application: UIApplication);
  42. begin
  43.    // application has initialized, now we can create the main window
  44.    mainwindow:=TMyWindow(TMyWindow.alloc);
  45.    // initialize window in Objective-C style
  46.    mainwindow := TMyWindow(mainwindow.initWithFrame (UIScreen.mainScreen.bounds));
  47.    // activate and show the window
  48.    mainwindow.makeKeyAndVisible;
  49. end;
  50. function NSStr(const s: string): NSString;
  51. begin
  52.    // converting string to NSString (CFStringRef and NSString are interchangable)
  53.    Result:=NSString( CFStr(PChar(s)));
  54. end;
  55. var
  56.    pool    : NSAutoreleasePool;
  57. begin
  58.    // initialize foundation memory manger (aka autorelease pool)
  59.    pool := NSAutoreleasePool.alloc.init;
  60.    // launching main application loop
  61.    ExitCode:=UIApplicationMain(argc, argv, nil, NSSTR('TAppDelegate'));
  62.    // according to docs the UIApplicationMain never returns,
  63.    // but still the code present in the Obj-C main.m files
  64.    pool.release;
  65. end.
复制代码
上面代码编译后的效果:


Written from scratch simple arkanoid game UIKit and GoreGraphics games for iPhone/iPod.:
        

真的假的?准备开始支持iphone了?期待啊...

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册(注册审核可向QQ群索取)

x
回复

使用道具 举报

该用户从未签到

发表于 2010-11-8 14:05:02 | 显示全部楼层
哪个版本?怎么我的0.9.29没有这个选项?
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2010-11-8 13:09:51 | 显示全部楼层
太好了,pascal又可以发扬光大了
回复 支持 反对

使用道具 举报

  • TA的每日心情
    开心
    2021-8-26 17:08
  • 签到天数: 7 天

    [LV.3]偶尔看看II

    发表于 2010-10-27 08:01:38 | 显示全部楼层
    好啊!lazarus前途无量啊!我们中文社区要加快学习建设,发展为最好的中文lazarus社区。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2010-12-4 19:13:12 | 显示全部楼层
    在Mac OS上支持,我们windows系统的怎么办?
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2010-12-30 15:56:15 | 显示全部楼层
    没有iphone的环境进行测试
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2012-5-29 12:47:50 | 显示全部楼层
    Mac OS上也没有见这些选项,是需要另外安装一些插件之类的。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2012-5-29 15:22:17 | 显示全部楼层
    太好了  看来又要学习了
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2012-5-30 12:25:40 | 显示全部楼层
    现在还没支持把。。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2012-6-2 10:20:58 | 显示全部楼层
    看來前景一片大好
    回复 支持 反对

    使用道具 举报

    *滑块验证:

    本版积分规则

    QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

    GMT+8, 2025-5-2 23:35 , Processed in 0.030795 second(s), 10 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表