作者plover (○(* ̄中肯 ̄*)○)
站内Programming
标题Re: [请益] 没有想像中简单的小问题
时间Mon Mar 23 23:12:36 2009
用iPhone SDK写的..
main.m
------
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"HelloWorldAppDelegate");
[pool release];
return retVal;
}
HelloWorldAppDelegate.h
-----------------------
#import <UIKit/UIKit.h>
@interface MainView : UIView
{
UITextView *textView;
}
@end
@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MainView *myMainView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
HelloWorldAppDelegate.m
-----------------------
#import <UIKit/UITextView.h>
#import <UIKit/UIColor.h>
#import <UIKit/UIFont.h>
#import "HelloWorldAppDelegate.h"
@implementation MainView
-(id)initWithFrame:(CGRect) rect {
self = [super initWithFrame: rect];
if (self!=nil) {
textView = [[UITextView alloc] initWithFrame: rect];
textView.text = @" 3\n 345\n34567\n 345\n 3";
[self addSubview: textView];
}
return self;
}
-(void)dealloc {
[textView release];
[super dealloc];
}
@end
@implementation HelloWorldAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
CGRect windowBounds = screenBounds;
windowBounds.origin.y = 0.0;
self.window = [[[UIWindow alloc] initWithFrame: screenBounds]
autorelease
];
myMainView = [[MainView alloc] initWithFrame: windowBounds];
[window addSubview: myMainView];
[window makeKeyAndVisible];
}
- (void)dealloc {
[myMainView release];
[window release];
[super dealloc];
}
@end
--
赚赚稿费 XD
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.45.230.90
1F:推 hala932:就算现在看到MIPS都不惊讶了 123.192.12.32 03/24 01:16
2F:推 yoco315:是 plover 耶!!!!! (疯狂 XD 118.160.109.50 03/25 00:33