Implement UIButton, UITextField and UILabel programmatically in iPhone

This is the very simple application. In this application we will see how to implement TextField, Label and button programmatically in iPhone. So let see how it will work.

Step 1: Open the Xcode, Create a new project using View Base application. Give the application “Example”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: We need to add one resource in resource folder. Give the resource name “anim.png”.

Step 4: Open the ExampleViewController.h file and make the following changes in the file:

#import <UIKit/UIKit.h>
@interface ExampleViewController : UIViewController {

UITextField *textFieldRounded;
UILabel *label;
UIImageView *image;
UISlider *slider;

}

@property(nonatomic,retain) UITextField *textFieldRounded;
@property(nonatomic,retain) UILabel *label;
@property(nonatomic,retain) UIImageView *image;
@property(nonatomic,retain) UISlider *slider;

@end

Step 5: In the Example.m file make the following changes in the file:

#import "ExampleViewController.h"

@implementation ExampleViewController

@synthesize textFieldRounded,label,image,slider;

(void)dealloc
{
    [super dealloc];
    [textFieldRounded release];
    [label release];
    [image release];
    [slider release];
}

(void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
(void)viewDidLoad
{
    [super viewDidLoad];
   
   textFieldRounded = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 280, 31)];
    textFieldRounded.borderStyle = UITextBorderStyleRoundedRect;
    textFieldRounded.textColor = [UIColor blackColor];
    textFieldRounded.font = [UIFont systemFontOfSize:17.0];
    textFieldRounded.placeholder = @"Enter Your name";  //place holder
    textFieldRounded.backgroundColor = [UIColor whiteColor];
    textFieldRounded.autocorrectionType = UITextAutocorrectionTypeNo;  
     textFieldRounded.backgroundColor = [UIColor clearColor];
    textFieldRounded.keyboardType = UIKeyboardTypeDefault;  
    textFieldRounded.returnKeyType = UIReturnKeyDone;  
   
    textFieldRounded.clearButtonMode = UITextFieldViewModeWhileEditing;
   
    [self.view addSubview:textFieldRounded];
   
    textFieldRounded.delegate = self;
   
     
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self
               action:@selector(buttonPressed:)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"Button" forState:UIControlStateNormal];
    button.frame = CGRectMake(20, 108, 97, 37);
    [self.view addSubview:button];
   
   
    label = [[UILabel alloc] initWithFrame:CGRectMake(40, 243, 240, 21)];
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentCenter; // UITextAlignmentCenter, UITextAlignmentLeft

    label.text = @"Label";
    [self.view addSubview:label];
   
   
   
    CGRect myImageRect = CGRectMake(40.0f, 190.0f, 240.0f, 128.0f);
    image = [[UIImageView alloc] initWithFrame:myImageRect];
    [image setImage:[UIImage imageNamed:@"anim.png"]];
     image.backgroundColor = [UIColor clearColor];
    image.opaque = YES;
    image.alpha = 0;
    [self.view addSubview:image];
    [image release];
   
    CGRect frame = CGRectMake(18.0, 348.0, 284.0, 23.0);
    slider = [[UISlider alloc] initWithFrame:frame];
    [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    [slider setBackgroundColor:[UIColor clearColor]];
    slider.continuous = YES;
    slider.value = 0.0;
    [self.view addSubview:slider];
   
}

(IBAction) sliderAction:(id) sender{
    image.alpha = slider.value;
}

(IBAction) buttonPressed:(id) sender{
    [textFieldRounded resignFirstResponder];
        label.text = textFieldRounded.text;
}

(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
}

(void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here Example

Welcome to the new TUAW

Here’s to new beginnings. TUAW has had iterative redesigns since our inception in 2004 but we’ve always followed the same old “river” format seen on “weblog” sites around the world. While a chronological order made sense before the iPhone, iPad, Apple TV were unleashed upon the world, it seems we have outgrown the rather limiting format of having a mere 10 posts on a page. We’re also serving content to a wide range of users these days, from newbies to developers. How do we surface content in the least number of clicks to such a disparate audience?

Enter TUAW 3.0 — currently in beta as we have a few important features yet to come. Read on for a full tour of what we’re launching tonight, and a tease of what is yet to be installed.

Continue reading Welcome to the new TUAW

Welcome to the new TUAW originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 23:45:00 EST. Please see our terms for use of feeds.

Permalink | Email this | Comments

Upcoming Time Capsule tied to iCloud, caches software updates?

We recently reported that many Apple retail stores are running low on stocks of AirPort devices, and this is usually a strong indicator of an upcoming product refresh. 9to5 Mac has followed up on that and says its sources claim a refresh is indeed imminent. A new version of the Time Capsule, currently undergoing internal testing at Apple, will cache software updates for any devices that regularly connect to its Wi-Fi network. The device will “learn” which devices regularly connect to it and silently download updates for them in the background without user intervention.

This functionality will work for both Macs and iOS devices, enabling users to install software updates from local caches instead of waiting for them to download first. John Gruber of Daring Fireball also speculates this could enable devices such as the iPad and iPhone to perform software updates without being tethered to a Mac, as is currently required.

9to5 Mac points out this technology already exists in Mac OS X Server, although in a more simplistic form that downloads software updates of all types rather than device-specific varieties. They also speculate that these new Time Capsules could be tied into iCloud, caching music in a user’s online storage locker or large, frequently accessed files, and also providing user backups to iCloud.

No one knows for certain when such devices will debut, nor can we say with any certainty that they even exist. All we know thus far is that current stocks of AirPort devices are dwindling at some Apple stores, and while WWDC is expected to focus on software, that doesn’t specifically preclude the introduction of new hardware like a Time Capsule update.

Upcoming Time Capsule tied to iCloud, caches software updates? originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 20:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

iCloud icon revealed, LA Times says service will cost $25 annually

In what turned out to be a busy day for the future iCloud service, AppleInsider posted images of banners unveiling the new service’s brushed-metal icon at the Moscone Center, while the Los Angeles Times reported that iCloud will likely cost just US$25 a year. The L.A. Times also said Apple has sealed the deal with the last of the four major record labels for its upcoming cloud music service.

We reported Wednesday that parts of iCloud could be offered for free to those who purchase Mac OS X 10.7 Lion, but the $25 subscription fee for hosting music in the cloud might be a service that’s separate from the free parts. The interesting thing, however, has to do with the revenue split. The L.A. Times says the agreement has Apple sharing 70 percent of iCloud’s revenue with music labels and 12 percent with those who hold the songwriting rights. Apple will pocket the remaining 18 percent, or $4.50 out of every $25 subscription.

The article states that while iCloud will start with hosting music, it will branch out to movies, TV shows and other digital content, which we imagine will be the sort of content currently hosted by MobileMe. This fits with the rumors that iCloud will be superseding MobileMe.

We will have all of our iCloud answers on Monday, when TUAW will be hosting a live blog of Steve Jobs’ keynote from WWDC.

iCloud icon revealed, LA Times says service will cost $25 annually originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 20:15:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Pulse News app now saves and syncs

Pulse News app for the iPhone and iPad received a nice update today allowing selected stories to be saved and automatically synced to other Pulse News apps you have or retrieved via the web.

Sign-up for the service is free and can be done from within the Pulse News app. All that’s required is a user-name and a password. When you see a story you want to save, click on the star symbol. If, for example, you did that on your iPhone, you can pick up your iPad and the saved story will be there too, assuming you have a web connection. The story is also accessible from the Pulse.me website.

Saved stories can also be sent to Instapaper, Evernote or Read It Later. If you import newsfeeds from Google Reader, marked stories will also mark them in Google Reader. After some difficulty with iTunes this morning, I was able to download the app for both the iPhone and iPad. Saving a story on either device made it immediately available on the other. It’s a nice feature. With the links to the web component, I’d really like to be able to set up my master set of sources on one app and have them sync to the other, but at least for now, it’s not a feature Pulse provides.

Pulse News app now saves and syncs originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 20:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Guy Kawasaki to keynote MacTech Conference 2011

Former chief evangelist for Apple (back in the days when the Macintosh first launched) Guy Kawasaki will keynote MacTech Conference 2011, happening November 2-4 in Los Angeles. We reviewed Guy’s latest book, Enchantment earlier this year. I’ve read several of Guy’s books and recommend them all. If you’re looking for pieces of Apple history, check out The Macintosh Way (available as a free download) and Selling the Dream in particular.

We also attended MacTech Conference last year and were very impressed with the event. There are two tracks, one for IT professionals and one for developers. For an additional fee attendees will be able to take Apple Certification exams.

We’ll attend the 2011 MacTech Conference as well and provide coverage and interviews with attendees, including Kawasaki.

Guy Kawasaki to keynote MacTech Conference 2011 originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 19:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Crayola’s ColorStudio HD now available, iMarker at Best Buy

Griffin announced via its Facebook page that its collaboration with Crayola, ColorStudio HD for iPad, is now available. We first heard of it just before CES, when news of the app along with the new iMarker stylus came out. The US$29.99 marker-styled accessory allows kids — or any other coloring enthusiast — to color more than 50 interactive coloring pages. A trial mode, available if you download the map but do not own the stylus, allows you to paint three pictures with your finger.

iMarker is now available through Best Buy and Griffin’s site, and we will be getting our hands on it to give is a good run-through.

Crayola’s ColorStudio HD now available, iMarker at Best Buy originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 18:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Gourmet Live now available for iPhone

Gourmet Magazine closed shop a few years ago and has lived on through its Gourmet Live app for the iPad. A little less than a year after its iPad app debuted, the company rolled out an iPhone version. Both the iPhone and iPad app lets you browse recipes and read articles from their large collection of food-related content.

The system uses a single login so all your saved and purchased content is available on both iOS devices. The iPhone app also has push notifications and integrated support for Twitter and Facebook. The Gourmet Live app is available now for free from the App Store.

Gourmet Live now available for iPhone originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 17:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Battlefield: Bad Company 2 on iPad, X-Men Arcade out now on iOS

It’s Thursday again and that means more big profile releases in the App Store. This week there are two big titles out to play with, in addition to lots of other smaller releases. First up, Konami has released a port of the old X-Men: The Arcade Game on iOS, the side-scrolling beat-em-up from way back in 1992. It’s been updated with Game Center, but as with most of these old school games, the controls consist of a couple of onscreen buttons — not exactly ideal. Still, fans of the title will enjoy it, and the US$2.99 download price ain’t bad at all, especially since it’s a universal version.

And EA’s Battlefield: Bad Company 2 is now available on the iPad. It’s been out on the iPhone for a little while, but this high budget FPS is now playing on the bigger screen as well. There are three different control setups to play with, Game Center integration, and even full 6-player action on both Wi-Fi and 3G. At $9.99, it’s the very definition of a premium title, but as you probably know, EA has a big sale nearly every holiday, so just wait a while and you’ll probably see it cheaper.

Battlefield: Bad Company 2 on iPad, X-Men Arcade out now on iOS originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 16:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Tim Cook: Tablets will outsell PCs (no kidding)

Goldman Sachs analyst Bill Shope has been talking to Apple’s higher-ups lately according to BI (including COO Tim Cook), and that they’re extremely bullish on iOS devices, even more so than they’ve been in the past. That’s hardly surprising — not only would you expect Apple executives to be excited about Apple products, but the iOS platform has been rocketing up anyway. Anyone betting against it at this point would be nuts.

Still, Cook specifically is claiming that there’s “no reason why the tablet market shouldn’t eclipse the PC market over the next several years,” according to Shope. And while it seems hard to believe that the much larger PC market could ever be threatened by tablets, that’s exactly what’s been happening lately anyway. Shope’s report says he expects another big increase in iPad sales this quarter, which surely Cook and friends would agree with as well.

This also means that we’ll see some interesting announcements about iOS 5 next Monday for sure.

Tim Cook: Tablets will outsell PCs (no kidding) originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 15:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

TUAW’s Daily Mac App: Decompose

Decompose for Mac

Cutting out people, objects or even text from images for creation of new ones is an old-photoshopper’s favorite. But it’s not as easy as it looks and, for the most part, requires a steady hand and some pricey software.

Decompose is a program that does one thing — it extracts foreground objects for overlaying on other images. Now, for those of you who are proficient with Photoshop, you’re not going to find much value in a US$29.99 app that extracts elements in this way. But for those of us who don’t own Photoshop, or even Pixelmator, having a program that allows you just to roughly draw around your target object letting the computer take care of the rest is great.

Decompose resultIn testing, I was a little skeptical, but on several, admittedly plain images, I was really impressed with the ease of use and end result of using Decompose. You simply outline the object within the “Contour” mask, fill in the rest of the image within the “Front” mask, and hit “Result.” Decompose then does its thing, using Grand Central Dispatch as of a recent update, and shows you the result for fine tuning or saving as a color-corrected TIFF. It was fast, simple and a great alternative to much higher priced packages.

The problem is that Decompose is a single use program, and therefore, however clever the programming behind it may be, $30 could be asking a little too much. Still, if you’re looking for a program that will quickly and easily extract objects out of photos, Decompose certainly gets the job done.

If you’ve got a quick and handy image extraction alternative to Decompose, help your fellow TUAW readers out and let us know in the comments.

TUAW’s Daily Mac App: Decompose originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 15:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Roundup of Kickstarter Apple-related projects for 6/2

For many tech startups, Kickstarter is a great way to raise funding to get a new company off the ground. Each week, TUAW takes a close look at recent Apple-related Kickstarter projects for those of you interested in supporting one of the many entrepreneurs who are waiting to bring the next big thing to market. Send us information about your Kickstarter project by using the tips and feedback link at the top of this page, and include the word “Kickstarter” in the subject line.

Artistree Dual-Tip Stylus

Artists who use the iPad as a drawing pad often have to switch between using their fingers and styluses with different tip sizes to get just the effect they desire onto their digital canvas. Now Matt Geyster is trying to solve that problem with the Artistree Dual-Tip Stylus.

One end of the capacitive stylus has a rounded tip that can be used for rough sketches, while the other has a thin, pointed tip for detail work. In between is an anodized aluminum body with soft silicone grips that looks much more like a comfortable pen than a typical iPad stylus. Geyster has plans to offer other interchangeable tips in the future to make the Artistree even more useful.

Matt’s project is a bit behind the eight-ball right now — he needs $30,000 to start production, but currently has 36 backers and less than $1,000 with a little more than a month to go. If you’re an iPad artist or just want a comfortable capacitive stylus to use for taking handwritten notes, look into backing the project.

Continue reading Roundup of Kickstarter Apple-related projects for 6/2

Roundup of Kickstarter Apple-related projects for 6/2 originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 14:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Official WWDC app available now

Apple has released an official WWDC app for next week’s developer conference, now available for both iPhone and iPad. The app includes a full schedule of events and the ability to make up your own custom schedule, detailed floor maps to see where everything is, and even up-to-date conference news and photos straight from the event (once it starts). There’s also a reservation system built into the app, so developers in attendance can reserve time in any of the conference’s labs.

The universal app is a free download, though it looks very different on the smaller screen than the bigger one. WWDC starts next week, everybody! Are you excited?

Official WWDC app available now originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 14:15:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Dear Aunt TUAW: Help me join my life, my heart, my iTunes account

Dear Auntie TUAW,

Can you believe my wedding is in a few weeks?! That’s got me thinking all of our digital goods that we now will both share.

While I would like to know if it is possible to combine 2 iTunes libraries and still keep metadata (like play counts and composers), I am more concerned with the number of Apple ID’s that will be under 1 roof.

I’ve got an old Apple ID that I’ve made a LOT of purchases with, both hardware and digital goods. In January, I purchased MobileMe, mostly to keep our calendars in sync on 3 macs and 2 iPhones, but I would also like for that me.com address to be my new Apple ID for purchases in both the iTunes store and the Mac App Store (especially for syncing apps on all the machines).

Can I just use that ID on all machines? What happens to my purchase history, like all my apps, movies, and anything with DRM? And of course, my future wife has her own Apple ID as well. Is it possible to bring all this together? And don’t worry, the band will play a polka the first set, just for you. Thanks!

Love and happiness,

Dave

Continue reading Dear Aunt TUAW: Help me join my life, my heart, my iTunes account

Dear Aunt TUAW: Help me join my life, my heart, my iTunes account originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 13:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Foxconn iPad factory resumes operation

A Foxconn factory in Chengdu, China that was damaged in an explosion on May 20 has been reopened less than two weeks later, according to a report in the Wall Street Journal. The explosion, which killed 3 workers and injured more than 15 others, was apparently caused by combustible dust used in polishing workshops. Foxconn hasn’t disclosed the results of its completed investigations, which Apple also reportedly took part in.

The reopening of production activities at this plant should relieve concerns of financial analysts, many of who anticipated a shortfall of iPad 2 units as a result of the incident. It was thought that the Chengdu plant accounted for as much as 30% of all iPad production and that the explosion would further constrain supplies of the popular tablet — now analysts believe that many of the constraints are due to “yield issues on certain outside components” and that production of the iPad 2 will remain constrained during the June quarter.

Foxconn iPad factory resumes operation originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 02 Jun 2011 12:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments