Monday, May 18, 2009

iPhone

Well it been a while since I wrote something. Things has changed the main focus is iPhone. I'm going to some easy tutorial of things I hard time with.
Let's begin with some basic UI elements:

UITextField
Code:
UITextField *username =[[UITextField alloc] initWithFrame:CGRectMake(24.5, 65, 270, 30)];
username.delegate=self;
username.textAlignment=UITextAlignmentCenter;
username.borderStyle=UITextBorderStyleRoundedRect;
username.placeholder=@"Username\n";
username.autocorrectionType=UITextAutocorrectionTypeNo;
username.autocapitalizationType=UITextAutocapitalizationTypeNone;
[self.view addSubview:username];

UIActionSheet
Code:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"This is where the information will go"
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:@"Email", @"Tech Support",@"Website",@"Cancel", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
actionSheet.destructiveButtonIndex = 3; // make the second button red (destructive)
[actionSheet showInView:self.view];
[actionSheet release];
Selecting a button on UIActionSheet
Code:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0){
// do stuff
}
}

UISwitch
Code:
UISwitch *switchIt = [[UISwitch alloc] initWithFrame:CGRectZero];
switchIt.on=NO;
[self.contentView addSubview:switchIt];
UILabel
Code:
UILabel *usernameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
usernameLabel.text=@"Personal Location Checkin";
usernameLabel.adjustsFontSizeToFitWidth=YES;
[self.contentView addSubview:usernameLabel];
UISearchBar
Code:
UISearchBar *mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
mySearchBar.delegate = self;
mySearchBar.showsCancelButton = YES;
mySearchBar.barStyle=UIBarStyleBlackOpaque;
mySearchBar.placeholder=@"Enter Name or Phone Number";
mySearchBar.keyboardType=UIKeyboardTypeNamePhonePad;


[self.view addSubview: mySearchBar];
UIView
Code:
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor grayColor];
self.view = contentView;
[contentView release];
UITableView
Code:
UITableView *myBeaconsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
myBeaconsTableView.delegate=self;
myBeaconsTableView.dataSource=self;

[self.view addSubview:myBeaconsTableView];
Or to make a grouped table view (like in preferences)

Code:
UITableView *settingsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 40, self.view.bounds.size.width, 375) style:UITableViewStyleGrouped];
settingsTableView.delegate=self;
settingsTableView.dataSource=self;
[self.view addSubview:settingsTableView];
UINavigationBar
Plain no Title
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
[self.view addSubview:myNavBar];
Black Opaque (no title)
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
myNavBar.barStyle=UIBarStyleBlackOpaque;
[self.view addSubview:myNavBar];
Black Translucent (no title)
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
myNavBar.barStyle=UIBarStyleBlackTranslucent;
[self.view addSubview:myNavBar];
To add title and other buttons

Code:
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"Around Me"];
[myNavBar pushNavigationItem: navItem];
To add buttons with image
Code:
refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(action:)];
[navItem setLeftBarButtonItem:refreshButton];
Add button with Text
Code:
refreshButton = [[UIBarButtonItem alloc] initWithTitle:@"About Us" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];
[navItem setRightBarButtonItem:refreshButton];
How to add comments
Code:
When you want to add a comment about a line of code you do this

// Comment

To do a multi-lined comment you would do this

/* This
is
multi-lined
comment
*/
UIWebView
Code:
dailyWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
dailyWebView.delegate=self;
dailyWebView.scalesPageToFit=YES;
[dailyWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
[self.view addSubview:dailyWebView];
UITextView
Code:
UITextView *textView = [[[UITextView alloc] initWithFrame:frame] autorelease];
textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Helvetica" size:15];
textView.delegate = self;
textView.backgroundColor = [UIColor whiteColor];

textView.text = @"TEXT TO GO IN HERE";
[self.view addSubView:textView];

UISegmentedControl
Code:
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"segment_check.png"],
[UIImage imageNamed:@"segment_search.png"],
[UIImage imageNamed:@"segment_tools.png"],
nil]];
frame = CGRectMake( 0,
0,
self.view.bounds.size.width,
35);
segmentedControl.frame = frame;
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;
[self.view addSubview:segmentedControl];
UIAlertView
Code:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"Your message"
delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1", @"Button2", nil];
[alert show];
[alert release];

This is just some UI elements that can be added through code

2 comments:

Anonymous said...

Do You interesting how to [b]Buy Viagra per pill[/b]? You can find below...
[size=10]>>>[url=http://listita.info/go.php?sid=1][b]Buy Viagra per pill[/b][/url]<<<[/size]

[URL=http://imgwebsearch.com/30269/link/viagra%2C%20tramadol%2C%20zithromax%2C%20carisoprodol%2C%20buy%20cialis/1_valentine3.html][IMG]http://imgwebsearch.com/30269/img0/viagra%2C%20tramadol%2C%20zithromax%2C%20carisoprodol%2C%20buy%20cialis/1_valentine3.png[/IMG][/URL]
[URL=http://imgwebsearch.com/30269/link/buy%20viagra/3_headsex1.html][IMG]http://imgwebsearch.com/30269/img0/buy%20viagra/3_headsex1.png[/IMG][/URL]
[b]Bonus Policy[/b]
Order 3 or more products and get free Regular Airmail shipping!
Free Regular Airmail shipping for orders starting with $200.00!

Free insurance (guaranteed reshipment if delivery failed) for orders starting with $300.00!
[b]Description[/b]

Generic Viagra (sildenafil citrate; brand names include: Aphrodil / Edegra / Erasmo / Penegra / Revatio / Supra / Zwagra) is an effective treatment for erectile dysfunction regardless of the cause or duration of the problem or the age of the patient.
Sildenafil Citrate is the active ingredient used to treat erectile dysfunction (impotence) in men. It can help men who have erectile dysfunction get and sustain an erection when they are sexually excited.
Generic Viagra is manufactured in accordance with World Health Organization standards and guidelines (WHO-GMP). Also you can find on our sites.
Generic [url=http://viagra.deutafilm.ru]buy generic viagra online in canada[/url] is made with thorough reverse engineering for the sildenafil citrate molecule - a totally different process of making sildenafil and its reaction. That is why it takes effect in 15 minutes compared to other drugs which take 30-40 minutes to take effect.
[b]viagra no rx
straight drugged viagra
viagra classification
viagra for cheap
Viagra too Expensive
viagra pic
keyword viagra sale
[/b]
Even in the most sexually liberated and self-satisfied of nations, many people still yearn to burn more, to feel ready for bedding no matter what the clock says and to desire their partner of 23 years as much as they did when their love was brand new.
The market is saturated with books on how to revive a flagging libido or spice up monotonous sex, and sex therapists say “lack of desire” is one of the most common complaints they hear from patients, particularly women.

Anonymous said...

Message37, http://www.arlo.net/massacree/ viagra online in uk, wsuw1, http://www.arlo.net/fccgb/ order viagra no prescriptions, clpa4, http://www.arlo.net/fccgb/notes/ buy generic viagra, afzd1, http://www.arlo.net/bytes/ buy cheap viagra online, krsu1, http://www.arlo.net/live/ viagra for sale

cms and stuff - new iPhone :)