Re: [請益] 沒有想像中簡單的小問題
用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
推
03/24 01:16, , 1F
03/24 01:16, 1F
推
03/25 00:33, , 2F
03/25 00:33, 2F
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章
7
20