This is Part 3 of 3 for my NSXML Parser Tutorial. Part 1 – www.youtube.com Part 2 – www.youtube.com
Source : iphonedevx[dot]com
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
This is Part 3 of 3 for my NSXML Parser Tutorial. Part 1 – www.youtube.com Part 2 – www.youtube.com
Facebook today announced a major revamp coming to its signature News Feed every user sees when they launch the Facebook app or login to Facebook on the desktop. The updated News Feed is heavily inspired by Facebook’s mobile app, which was first developed for iOS.
While there are several changes to the News Feed coming, the most obvious will appear in the desktop browser. Now Facebook’s website will feature the same left-side navigation browser that users reveal on its iOS apps by swiping to the right. In addition, significant changes are coming to the way the News Feed is displayed on the iPhone and iPad. From Facebook’s press release today:
Today we’re announcing a new version of Facebook designed to reduce clutter and focus more on stories from the people you care about. You see all the stories you saw in your News Feed before, but with a fresh new look. We’ve completely rebuilt each story to be much more vibrant and colorful and highlight the content that your friends are sharing. Photos, news articles, maps and events all look brighter and more beautiful.
To make sure you’re seeing all the stories you want to see, we’re introducing several new feeds to explore in addition to the same News Feed you have today:
- All Friends – a feed that shows you everything your friends are sharing
- Photos – a feed with nothing but photos from your friends and the Pages you like
- Music – a feed with posts about the music you listen to
- Following – a feed with the latest news from the Pages you like and the people you follow.
The new News Feed rollout won’t rollout won’t go live for everyone for a few weeks. Those wishing to get started early can visit www.facebook.com/about/newsfeed and add themselves to the waiting list.
Facebook previews upcoming app-inspired newsfeed for desktop and mobile originally appeared on TUAW – The Unofficial Apple Weblog on Thu, 07 Mar 2013 19:00:00 EST. Please see our terms for use of feeds.
Introducción a la Programación en iOS
Image by Nearsoft
@ Summer Talks 2011
It’s the TUAW Daily Update, your source for Apple news in a convenient audio format. You’ll get all the top Apple stories of the day in three to five minutes for a quick review of what’s happening in the Apple world.
You can listen to today’s Apple stories by clicking the inline player (requires Flash) or the non-Flash link below. To subscribe to the podcast for daily listening through iTunes, click here.
No Flash? Click here to listen.
Daily Update for March 6, 2013 originally appeared on TUAW – The Unofficial Apple Weblog on Wed, 06 Mar 2013 18:15:00 EST. Please see our terms for use of feeds.
Artfinder is a magazine jam-packed with feature stories, exclusive interviews and beautiful collections; a wish list where you can save your favorite works of art and make purchases with just a few taps; and the art of the day, which will hopefully inspire you and teach you a little something about the creativity in the world around you.
Click “more” to see for yourself.
Like the article? You should subscribe and follow us on twitter.
Artfinder will prompt you to connect to the app using an email address and/or your Facebook account. If you think there’s a chance you’ll want to receive alerts as to when new Art of the Day or special offers have been added, then signing up for an account with your email address is a must.
Artfinder is a magazine all about art — but you can buy the pieces you like! Check out features like Art of the Day, Abstract Art, Photography, Features and others.
Artfinder displays all its content in well-labeled squares that are easy to scroll through. Categories include Abstract Art, Editor’s Picks, Artists to Watch, 60-Second Interviews, Photography, Guides, Gallery of the Week, Style and Trends, Learn, specific artist features, and so many others.
Swipe to the right at any time in order to reveal the menu, where you can access the Magazine, your Profile and Feedback (where you can contact Artfinder directly).
While you’re browsing, click on any individual square of content for more information. Or, to view the menu, swipe anywhere on the screen to the right. A gray menu will be revealed, featuring the following tabs:
Home: What’s new on Artfinder
Magazine: Stories, interviews and collections
Profile: Browse your wish list and manage your settings
Feedback: Let Artfinder know your thoughts
Tap on any work of art for background on the artist and details about the individual piece.
In the Magazine, click on any item for more information, including any of the Art of the Day. You’ll be able to see the entire work of art, plus read about the artist and view other works by the same artist. See something you like? Click the star icon at the top of the page to save it to your favorites. Also, you can share the art via email and social media using the Share button at top right.
You can also view details on the partner (gallery), view price, edition number, and other must-know information for art enthusiasts.
And if you come across a piece you decide you just can’t live without, I have good news: It can be yours. Go ahead and click that Buy button to view the full damage — I mean, grand total — including the cost of shipping.
Artfinder’s extends a promise to its customers: It offers every customer a 30-day, no-risk, money-back guarantee, and will arrange the collection of any purchase at no cost to the customer.
While the Feedback tab provides you with a way to easily contact the Artfinder team, the Profile tab enables you to easily adjust your settings, including whether you want to receive notifications from Artfinder for a new Art of the Day or special offers.
Sign up for an account with Artfinder if you want to receive alerts about new Art of the Day and special offers.
From the Profile tab you can also view your wish list items, meaning all the works of art you’ve starred while browsing the app’s content. Click on any artwork for more information or to make a purchase.
If you have any appreciation whatsoever for art — or even if you don’t — you may be surprised at how much time you end up spending scrolling through all the works of art and lusting after certain pieces.
At the most, you may discover an artist or piece that resonates with you so deeply that you just have to have it. And at the least, you will garner some creative inspiration or a few minutes to relax and tap into the more artistic side of your mind. The app’s simplicity, as well as its well-organized and easy-to-navigate format, make it that much easier to get lost in.
Important things to know before you start development, Honestly this should be the first lesson before starting development iphone development tutorial “Macworld” “expo” “steve” “jobs” “iphone” “ipod” “apple” “touchscreen” “keynote” “nano” “video” “iphone” “sdk” “development” “tutorial” “app” “store” “beginner” “getting” “started” “hello” “world” “xcode” “iphone” “sdk” “development” “programming” “objective-c” “iphone development tutorial” “app” “store” “beginner” “getting” “started” “hello” “world” “iphone” “dev” “tutorial”
Having tried some traditional Sonic the Hedgehog gameplay with Sonic Episode 4 (which didn’t seem to do that well for them), Sega has now moved to the strategy of using Sonic in much simpler, arcade-style iOS games. Sonic Jump came out a little while ago, featuring an endless jumping/Doodle Jump-esque premise, and now Sega has announced Sonic Dash, an endless running game featuring all of the series’ mainstays.
It’s a 3D game, however, so it’ll likely have a lot of similarities to Temple Run, which is certainly a franchise that a lot of game developers have been emulating lately. Sonic Rush is due out “soon” on the App Store, which probably means later on this week. We’ll keep an eye out for it then.
Sega announces Sonic Dash, an endless runner starring the blue hedgehog originally appeared on TUAW – The Unofficial Apple Weblog on Tue, 05 Mar 2013 19:00:00 EST. Please see our terms for use of feeds.
Objective-C® for Dummies® by Neal Goldstein, Copyright © 2009 by Wiley Publishing, Inc., is the main source of information for this video. In this lesson we go into Xcode and try out what we learned in Part 1. Twitter – twitter.com FaceBook – www.facebook.com E-mail – macandcomputerhelp@gmail.com Objective-C Tutorial objective-c tutorial objective c tutorial
Video Rating: 4 / 5
In this application we will see how to hide button from the iPhone application. So let see how it will worked.
Step 1: Open the Xcode, Create a new project using Single View Application. Give the application
“ButtonHide”.
Step 2: Need to add new viewController class in the project. Select project -> New file ->
UIViewController subclass -> next -> Give the application name “ButtonHideView”.
Step 3: Now open the AppDelegate.h file and make the following changes:
@class ButtonHideView;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
ButtonHideView *buttonHideView;
}
@property (nonatomic, retain)IBOutlet ButtonHideView *buttonHideView;
@property (strong, nonatomic) UIWindow *window;
@end
Step 4: In the AppDelegate.m file make the following changes:
@implementation AppDelegate
@synthesize window = _window,buttonHideView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
buttonHideView = [[ButtonHideView alloc]
initWithNibName:@"ButtonHideView"
bundle:nil];
[_window addSubview:buttonHideView.view];
return YES;
}
@end
Step 5: Now open the “ButtonHideView.h” file and make the following changes:
@interface ButtonHideView : UIViewController
{
IBOutlet UIButton *button1;
IBOutlet UITextField *textfield1;
}
@property (nonatomic, retain) IBOutlet UIButton *button1;
@property (nonatomic, retain) IBOutlet UITextField *textfield1;
-(IBAction) ButtonHide:(id)sender;
//}
@end
Step 6: Double click the ButtonHideView.xib file and open it to the Interface Builder. First drag the
UIButton and UITextField from the library and place it to the view window. Select the button from
the view window and bring up connection inspector and connect touch up inside to the File’s Owner
icon and select “ButtonHide:” method and connect the File’s owner icon to the textfield and select
“textfield1”. Now save the .xib file, close it and go back to the Xcode.
Step 7: In the ButtonHideView.m file make the following changes:
@implementation ButtonHideView
@synthesize button1,textfield1;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(IBAction) ButtonHide:(id)sender
{
if([textfield1.text isEqualToString: @""]){
button1.hidden = YES;
} else {
button1.hidden = NO;
}
NSLog( @"%@", textfield1.text );
}
@end
Step 8: Now Compile and run the application on the Simulator
A few years ago, xkcd created a crowd-sourced color survey to collected real-world hue descriptions. You’ll find the hilarious results here.
I’ve been working on updating my UIColor utilities as part of building a color sampling app. Stumbling across this survey, I decided to add the xkcd colors to my repository, along with code that matched colors to their nearest xkcd equivalents.
What I found is that as delightful as the sourced color descriptions are, that they were rather full of misspellings, for example “urple”.
So I put together a simple NSString category to find misspellings and “creatively” described colors. I found this approach to be useful enough that I decided to share it on a DevJuice.
Normally, you use text checkers to find misspellings in text view and fields, and to present those items to the user. But you’re certainly not limited to that scenario. This simple string category lets you test whether a misspelled word was found, enabling me to automate my inspection.
I loaded up the xkcd names as an array and searched them to find any potential errors. Out of nearly a thousand color names, it quickly flagged about two dozen issues — saving a huge amount of detail checking.
This doesn’t of course, guarantee the correctness of my results. I know I left in a few amusing misspellings: “Blurple,” for example, plus if any misspellings ended up as a legal English word, they will not have been flagged.
What’s more I had to bowdlerize some entries. Apple does not have any “offensive language” tester that I could find. (Know of one? Please ping me about it!) So I had to update those items by hand.
In any case, I hope you’ll find this useful. Happy coding!
DevJuice: Spellchecking short strings originally appeared on TUAW – The Unofficial Apple Weblog on Mon, 04 Mar 2013 19:00:00 EST. Please see our terms for use of feeds.
Welcome back to the weekly feature of the most popular new resources mentioned on the site in the past week.
This weeks most popular resource is alibrary providing helper methods for creating complex queries of Objective-C collections.
Here are the top 3 resources for the last week:
1. NSEnumaratorLinq - A library providing Microsoft .NET style query methods for Objective-C classes. (featured here) (share on twitter)
2. iOS Passbook Tutorial - A tutorial showing how to create a simple passbook service and app utilizing that service. (featured here) (share on twitter)
3. MBPullDownController - An open source control allowing you to supply a front and back view, and the front view can be pulled down to reveal the back view. (featured here) (share on twitter)
Thanks for reading!
Original article: Top iOS Development Resources For Week Ended March 3rd, 2013
©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
Question by Teeter: What are some magazines that are in print for development and programming?
I need one that actually mails out, not online. Can be about:
* Website development
* Website programming
* Website design
* Database programming
* Linux or linux server administration
* Open source software
* Mac programming or iPhone programming (there are probably not very many of these)
* Specific languages: Java, Javascript, HTML
Best answer:
Answer by Victor
I used to subscribe to Linux magazine. Good insight on upcoming items and code snippets on hot topics. Good read. Recommended.
see:
http://www.linux-mag.com/contact
Give your answer to this question below!
Description: Objective-C video tutorials — In these programming video series I’ll go through the basics of objective-c object oriented programming language. Objective-c is the programming language of Apple Mac OSX Operating system and the language of iOS. So if you want to develop applications for Mac, iPhone, iPad, and iPod touch then you have to master objective-c programming language. It’s one of the best programming language and it’s easy to learn. It is derived from the C language but it’s Object-oriented which makes it better. These video tutorials are for beginners and gradually we’ll discuss the advanced part of objective-c as time goes on. If you have any questions drop a comment. And don’t forget to rate and like all the videos to allow others to benefit from these objective-c video tutorials.
Lunatik burst onto the Apple accessory market in 2010 in one of the early successful uses of Kickstarter, coming out with a pair of iPod nano watch cases called the TikTok and LunaTik. Now the company is introducing a line of iPhone 5 cases that feature rugged designs to protect your investment.
Lunatik designs are the brainchildren of Chicago-based designer Scott Wilson and his design firm Minimal. The company has more than just a handful of Kickstarter projects behind it; Minimal has been involved with design work for Microsoft, Nike and other big-name corporations.
Lunatik provided TUAW with four of their latest iPhone 5 case designs. We’ll take a close look at all four, then give you a chance to win one of the cases to keep your iPhone 5 safe and stylish.
Flak
Flak (US$34.95) looks like a fairly minimalist iPhone 5 case, but uses a deceptively simple dual-layer interlock construction method to protect your phone from impact with a tough outer impact shell and a shock absorbing inner core.
That external impact shell is made of a glossy polycarbonate that comes in either white, black, red or pink, while the inner core uses soft TPU to cradle your iPhone 5 without scratching it. The Flak flexes just enough to make inserting the iPhone a piece of cake. The Flak has pass-through buttons for volume control and sleep/wake/on/off, while the mute button is left open for easy access.
If I have one complaint about the design of the Flak, it’s that the polycarbonate really attracts dust, fingerprints and smears easily. After a bit of handling to try it out, I had to wipe the Flak down before taking photos and still ended up with a lot of dust speckles…
Seismik
I started my professional career a few centuries ago as a civil engineer, so I understand the power of the truss to stiffen structures. In the Siesmik ($34.95), Lunatik is using a truss design to stiffen a flexible TPU material. The result is a case that can use the cells in the flexible truss to cushion drops, but it’s stiff enough to not feel like the typical “gummy” TPU case.
The Seismik comes in five different color schemes: all black, gray and cyan, gray and yellow, gray and clear, and gray and magenta. If you’re looking for a case with a good grippy surface, the Seismik is it. This would be perfect for carrying a phone around in your hand on a hot, sweaty day; it’s not going to slide out of your hand unless you deliberately drop it.
Taktik Strike
Now we’re getting into the amazing cases. The Taktik Strike ($79.95) has been designed to provide protection against shocks and drops, and it is built like a tank — literally. The Taktik Strike takes the truss design of the Siesmik and wraps it in thick polymer bezels held together with steel and aluminum hardware.
It’s not designed to protect your iPhone 5 from the weather — we’ll get to that case in a minute – but it will definitely keep it from being damaged from most falls except for one that takes it face-forward onto a metallic object. All of the buttons on the device are covered, and ports are given the plug-and-cover treatment.
Anyone who is a fan of minimalist iPhone cases won’t be thrilled with the Taktik Strike, as it is definitely chunky and built for rugged protection of your phone investment. The bezels come in black, gray, green, white and pink to match your personal preference.
Taktik Extreme
If you’ve made it this far, you’ll notice a theme — these cases are getting more and more protective as we go along. The Taktik Extreme ($124.95) is the ultimate in iPhone 5 protection. There’s seriously no case like it around, as it takes the Taktik Strike’s design even further with a cover over the iPhone’s lower bezel and Home button and Corning Gorilla Glass over the entire screen.
The plugs on the Taktik Extreme are water and dust resistant, providing weather protection. It’s not advertised as being waterproof, but it should be able to handle being rained on or getting the occasional splash.
That Gorilla Glass provides shatter protection for the screen in those rare cases where you drop the iPhone right onto a hard edge. All of this protection does come at a price, and I’m not talking about the $125 price tag. The Taktik Extreme weighs in at 4.1 ounces, significantly more than the lightweight (1.3 ounce) Seismik.
Conclusion
Lunatik has brought a nice combination of savvy design and rugged engineering to the crowded iPhone case market, and the products will go far in attracting fans. The two Taktik cases, Strike and Extreme, could be fierce competitors to the likes of OtterBox and LifeProof
Giveaway
It’s your chance to win one of these four awesome cases from Lunatik. Here are the rules for the giveaway:
Loading…
Lunatik unleashes four tough iPhone 5 cases originally appeared on TUAW – The Unofficial Apple Weblog on Sun, 03 Mar 2013 19:00:00 EST. Please see our terms for use of feeds.
Every since updated my iPhone 5 and iPad 3 to iOS 6.1.2, Siri will not launch any apps except Apple own. After every other request, Siri replieswith the response, "I don't see an app named".
How to use the NSMutableArray class in Objective-C.
Video Rating: 5 / 5
Previously I mentioned a great control for creating customized bar indicators and the popular MBProgressHud for creating custom progress indicators.
Here’s a control called DPMeterView from Pierre Dulac that you can use to create custom gauges with any image. The control provides methods so that the gauge can easily be used as progress indicators or rating indicators. The gauges are animated, and there’s even a way to set up gravity for the gauges so the indicated fill adjusts for the tilt of the phone.
There are a number of examples providing included a star rating indicator. You can follow the included examples and create your own custom indicators using core graphics.
Here’s an image from the readme showing the included example indicators with gravity on a tilted device:
You can find DPMeterView on Github here.
A great control for creating custom gauges.
Original article: Open Source Control For Creating Custom Image Based Indicators For Ratings, Gauges, Progress And More
©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
THE #1 BESTSELLING BOOK ON OBJECTIVE-C 2.0
Programming in Objective-C 2.0 provides the new programmer a complete, step-by-step introduction to Objective-C, the primary language used to develop applications for the iPhone, iPad, and Mac OS X platforms. The book does not assume previous experience with either C or object-oriented programming languages, and it includes many detailed, practical examples of how to put Objective-C to use in your everyday iPhone/iPad or Mac OS X progr
List Price: $ 44.99
Price:
Description: Objective-C video tutorials — In these programming video series I’ll go through the basics of objective-c object oriented programming language. Objective-c is the programming language of Apple Mac OSX Operating system and the language of iOS. So if you want to develop applications for Mac, iPhone, iPad, and iPod touch then you have to master objective-c programming language. It’s one of the best programming language and it’s easy to learn. It is derived from the C language but it’s Object-oriented which makes it better. These video tutorials are for beginners and gradually we’ll discuss the advanced part of objective-c as time goes on. If you have any questions drop a comment. And don’t forget to rate and like all the videos to allow others to benefit from these objective-c video tutorials.
The wait for an iPhone may finally be over this year for customers on the China Mobile TD-LTE network, reports Patently Apple.
China Mobile confirmed at Mobile World Congress in Barcelona this week that it will be running tests of its TD-LTE network in more than 100 cities in China, which will provide fast data service to a potential customer base of over 500 million people.
The news follows reports that Apple supplier Qualcomm is producing a new solution that supports all available LTE implementations and that would allow phone manufacturers to provide a single mobile device that would provide global LTE roaming support. If Apple chooses to use this solution — which also provides more efficient use of battery power — in an upcoming iPhone, it could open the door to even more dynamic growth in sales of Apple’s flagship product.
China Mobile preps for iPhone with TD-LTE service originally appeared on TUAW – The Unofficial Apple Weblog on Fri, 01 Mar 2013 18:30:00 EST. Please see our terms for use of feeds.
Researchers at Oxford University are working on technology that would let you ride in a self-driving car that’s partially controlled by an iPad. According to a report in Clean Technica, the RobotCar UK project is headed up by Professor Paul Newman of Oxford University’s Department of Engineering Science.
The computer-controlled system uses sensors on the outside of a Nissan Leaf to generate a detailed picture of the car’s surroundings. An iPad sits in the dashboard and is the control panel that lets the user interact with the system. With just a few taps, the driver can turn auto-drive on and off.
The research team is still in the early stages of testing the self-driving system. It’ll take some time for the technology to improve and for the cost to drop from its prototype price of £5,000 down to a consumer-friendly £100.
You can check out a video of the car in action below and let us know what you think in the comments. Would you ride in iPad-controlled self-driving car?
[Via AppleInsider and Clean Technica]
iPad navigates self-driving car originally appeared on TUAW – The Unofficial Apple Weblog on Fri, 01 Mar 2013 10:00:00 EST. Please see our terms for use of feeds.
Question by Advice Please: If you want to add data to an iphone script. What type of file do you do this with?
Also, can you submit an iphone programmed with a windows pc? I know it has to be coded on a mac, but if someone codes it and emails you the files, can they be forwarded onto apple this way? Can the windows person fill out a data file or does that have to also be done on a mac? Say I had a list of soups I wanted to have listed on the application. Can the windows pc create that list or does it have to be a mac file?
Best answer:
Answer by Rodrigo33024
You can import data to your iphone app by creating a plist or a sqlite file, they both can be created on a PC or mac, they are just text files with the information that you will be importing.
Once you have the plist or sqlite files you need to import them to xcode in the resources folder and your iphone application will need to be programmed to open the file, read its content and display it.
You will also need to recompile your app after that.
Know better? Leave your own answer in the comments!
The UINavigationController maintains a UIToolBar for each view controller in its stack. This toolbar is normally hidden, but we can place buttons on it and display it any time we want. Let’s see how this is done.
Start Xcode, select “Create a new Xcode project” and select the Empty Application template. Click Next, name the project ToolBarButtons, and choose options as shown:
Click Next, choose a location to save the project, and finally click Create. When the project has loaded, select the AppDelegate.m file, right-click that file, and select “New File” from the popup menu. (The reason we selected the AppDelegate.m file first is that Xcode will place newly created files immediately below the selected file in the navigator.)
Select the Objective-C class template, click Next, and name the class MainViewController. Make sure that the class is a subclass of UIViewController, and also create a XIB file for the controller’s view as shown:
Click Next, accept the default location, and click Create.
Now we’re going to set up a navigation controller having a MainViewController object as its root view controller. Select the AppDelegate.h file, and add the two properties for the UINavigationController and the MainViewController as shown:
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *navController;
@property (strong, nonatomic) MainViewController *rootViewController;
@end
Make sure that the MainViewController file is imported, otherwise we won’t be able to instantiate on object from it.
After adding the navController and rootViewController objects, Open the AppDelegate.m file, and make the following changes:
@implementation AppDelegate
@synthesize window = _window;
@synthesize navController = _navController;
@synthesize rootViewController = _rootViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.rootViewController = [[MainViewController alloc] initWithNibName:nil bundle:nil];
self.rootViewController.title = @"Main View";
self.navController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
[self.window addSubview:self.navController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
…
As always, we first synthesize our properties. We’ve only shown the application: didFinishLaunchingWithOptions: method here, because it’s the only method we will be making changes to. Leave the remaining methods in place.
First, we allocate and initialize the rootViewController. The nib name of nil in this case directs the compiler to associate this controller with the XIB file that was created with it (MainViewController.xib). A bundle of nil directs the compiler to use this application’s bundle. After we initialize this controller, we set its title to @”Main View.” This title will appear in the navigation bar for this view controller.
Next, we set up the navController object. We make rootViewController this object’s Root View Controller. Adding the navController’s view to the main window as a subview, we then make the main window key and visible, and we’re off and running.
In the MainViewController.xib file, choose a nice color for the view:
Since the view controller’s title property was set to @”Main View” in the AppDelegate, that title will appear at the top of the interface when we run the app:
Open the MainViewController.m file, and make these additions to initWithNibName: bundle:
First, we add a UIBarButtonSystemItemSearch button to the navigationItem’s rightBarButtonItems array. This button will be placed at the right of the top navigation bar. Next, we set up three bar buttons (btnRed, btnBlue, and btnGreen) and a spacer. The three buttons each have a selector, these will be defined shortly. Each also is initialized with a title, and a style of UIBarButtonItemStyleDone, which will produce a button with a blue background and white bolded text.
The function of the spacer is to add “flexible space” between btnBlue and btnGreen. Flexible space will act as a “spring” between the two buttons, pushing btnGreen all the way to the right of the tool bar. Since this space is invisible, it makes no sense to assign it an action method, so we have set both the target and action of this object to nil.
Now that we have the buttons, we need to add them to the tool bar. Each view controller has it’s own toolBarItems property, which is an NSArray of UIBarButtonItem objects. This line:
stuffs the toolBarButtons array with the three buttons and the spacer.
All that remains now is to implement the four methods we set as actions in the buttons:
- (void)btnRedTouched
{
self.view.backgroundColor = [UIColor redColor];
}
- (void)btnBlueTouched
{
self.view.backgroundColor = [UIColor cyanColor];
}
- (void)btnGreenTouched
{
self.view.backgroundColor = [UIColor greenColor];
}
toggleToolBar gets the hidden property of the tool bar, then sets that property to its negation. In other words, if the tool bar is hidden it will be shown, if it is shown it will be hidden.
The three btn…Touched methods set the color of the view’s background to red, cyan, or green when they are touched.
Run the app, and enjoy: