Sunday, January 5, 2014

Seeking pure source code to make the interface

If that.
Reply:
 
# Import
@ Class UITextView;

@ Interface HelloController: UIViewController
{
int value;
}
@ End

@ Implementation HelloController

- (Id) init
{
if (self = [super init])
{
self.title = [[[NSBundle mainBundle] infoDictionary] objectForKey: @ "CFBundleName"];
}
return self;
}

- (Void) goRed
{
self.view.backgroundColor = [UIColor colorWithRed: 1.0f green: 0.45f blue: 0.45f alpha: 1.0f];
}

- (Void) goBlue
{
self.view.backgroundColor = [UIColor colorWithRed: 0.45f green: 0.45f blue: 1.0f alpha: 1.0f];
}

- (Void) loadView
{
/ / Set up the text view to show the current value
UITextView * contentView = [[UITextView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]];

contentView.editable = NO;
contentView.textAlignment = UITextAlignmentCenter;
contentView.font = [UIFont fontWithName: @ "American Typewriter" size: 120];

contentView.autoresizesSubviews = YES;
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

self.view = contentView;
[ContentView release];

/ / Initialize at 50
[(UITextView *) self.view setText: @ "\ n50"];
value = 50;

/ / The app style is black
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

NSMutableArray * buttons = [[NSMutableArray alloc] initWithCapacity: 4];

UIBarButtonItem * flexibleSpaceItem;
flexibleSpaceItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace
target: nil action: NULL] autorelease];
[Buttons addObject: flexibleSpaceItem];
[FlexibleSpaceItem release];

UIBarButtonItem * item;
item = [[UIBarButtonItem alloc]
initWithImage: [UIImage imageNamed: @ "down.png"]
style: UIBarButtonItemStylePlain
target: self
action: @ selector (decrement :)];
[Buttons addObject: item];
[Item release];

item = [[UIBarButtonItem alloc]
initWithImage: [UIImage imageNamed: @ "up.png"]
style: UIBarButtonItemStylePlain target: self
action: @ selector (increment :)];
[Buttons addObject: item];
[Item release];

flexibleSpaceItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace
target: nil action: NULL] autorelease];
[Buttons addObject: flexibleSpaceItem];
[FlexibleSpaceItem release];

UIToolbar * toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleBlackOpaque;
[Toolbar setItems: buttons animated: YES];
[Toolbar sizeToFit];

self.navigationItem.titleView = toolbar;
[Toolbar release];

/ / Add a left button
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle: @ "Red"
style: UIBarButtonItemStylePlain
target: self
action: @ selector (goRed)] autorelease];

/ / Add a right button
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle: @ "Blue"
style: UIBarButtonItemStylePlain
target: self
action: @ selector (goBlue)] autorelease];
}

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
return YES;
}

- (Void) increment: (id) sender
{
[(UITextView *) self.view setText: [NSString stringWithFormat: @ "\ n% d", + + value]];
}

- (Void) decrement: (id) sender
{
[(UITextView *) self.view setText: [NSString stringWithFormat: @ "\ n% d", - value]];
}
@ End


@ Interface SampleAppDelegate: NSObject
@ End
@ Implementation SampleAppDelegate
- (Void) applicationDidFinishLaunching: (UIApplication *) application {
UIWindow * window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController: [[HelloController alloc] init]];
[Window addSubview: nav.view];
[Window makeKeyAndVisible];
}
@ End

int main (int argc, char * argv [])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain (argc, argv, nil, @ "SampleAppDelegate");
[Pool release];
return retVal;
}

This is?
Reply:
Thank you for your answer.

I now want to investigate UIWebView cache busy, so I have time to confirm next.
Reply:
This problem is so turned off, and what issues does not want to come.

In fact, I want a whole project, so that I can learn about the structure of the way. Examples of iphone's mostly to do with the IB, nothing can refer to.
Reply:
Passing, look

No comments:

Post a Comment