RSS

Category Archives: iOS

iOS Programming 101: Customize UITableView and UITableViewCell Background using Storyboard

January 6, 2013 by 

 

In the last tutorial of our iOS Programming 101 series, we showed you how to customize the navigation bar and buttons with your own background image. This time, we’ll look into the customization and styling of UITableView and UITableViewCell.

If you’ve followed our iOS tutorials from the very beginning, you know we’ve written a tutorial about customizing table view cell using Interface Builder. In this tutorial, we’ll do something different. Instead of using Interface Builder to tweak the UITableViewCell, we’ll show you how to use Storyboards to style the cell. Storyboards make customizing table cells much easier with the introduction of prototype cell. In brief, you’ll learn the following stuffs in this tutorial:

  1. Customizing UITableViewCell using Storyboard
  2. Style UITableViewCell and UITableView with your own background images

To illustrate the customization, we’ll tweak a simple table view, style it and make it more attractive. To help you focus on learning the customization, we’ve prepared the Xcode project for you to start with. Before proceeding, first download the Xcode project here (note: the project is created using Xcode 4.5).

Designing Prototype Cells in Storyboard

Since the release of iOS 5, Apple introduced Storyboarding that simplifies the way to design user interfaces for your app. To customize a table cell, you no longer need to create a separate cell in Interface Builder. You can design the cell right inside the Storyboard editor.

Open the Xcode project you’ve downloaded. Go to the Storyboard and you should see something like this:

Storyboard Empty TableViewController

Table View Controller with Empty Prototype Cell

When you add a UITableViewController in the Story, by default, you should see an empty prototype cell. You can now add other UI control elements (e.g. UILabel, UIImageView) right into the prototype cell. Let’s first change the height of the cell. Select the Prototype Cells, click the “Size” inspector and change the row height from 44 to 71.

CustomTableView - Change Row Height

Changing row height in Storyboard

Next, drag an Image View from object library to the prototype cell. Again, select the image view, click “Size” inspector and change the “X”, “Y”, “Width” and “Height” attributes as follows:

CustomTableView - Add Image View

Add image view to prototype cell

Switch to the “Attributes” inspector, set the “Tag” to 100. You can think of a tag as an unique identifier of the UI control. Later in our code, we’ll use this tag to identify the image view.

CustomTableView - Image Tag

Assigning a tag for the image view

Then drag a label to the cell and name it as “RecipeName”. This label is used to display the name of recipe. In the “Size” inspector, set “X” as 92, “Y” as 7, “Width” as 186 and “Height” as 21. In the “Attributes” inspector, change the font type to “Helvetica Neue Condensed Bold” and set the font size to 21 points. Finally, set the “Tag” value to 101.

CustomTableView - Add Labels

Add labels to the prototype cell

Add another label to the cell and name it as “Details”. In the “Size” inspector, set “X” as 92, “Y” as 32, “Width” as 186 and “Height” as 33. Switch to the “Attributes” inspector, set the “Tag” value as 102.

Coding the Table View Controller

With the user interface designed, let’s get back to the code. Open “RecipeViewController.m”, which is the corresponding class of the Table View Controller, change the “cellForRowAtIndexPath:” method to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @”Cell”;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

// Configure the cell…
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

// Display recipe in the table cell
Recipe *recipe = [recipes objectAtIndex:indexPath.row];
UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:recipe.imageFile];

UILabel *recipeNameLabel = (UILabel *)[cell viewWithTag:101];
recipeNameLabel.text = recipe.name;

UILabel *recipeDetailLabel = (UILabel *)[cell viewWithTag:102];
recipeDetailLabel.text = recipe.detail;

return cell;
}

We’ve added the code (from line 12 to 20) for displaying the cell labels and image view. As you can see from the code, we invoke the “viewWithTag:” method with the tag value to identify the UI component.

Compile and run the app. Your app should look like this:

CustomTableView - Initial App

Recipe Book App with default cell style

Styling the UITableCell with Background Image

Now you’ve learnt how to create custom table cell using Storyboard, but the table view cell is just in plain style. We want to change the look & feel of the table cells and make them prettier. In the Xcode project, you should find three background images for table cell. The images are specially designed for different types of cells.

CustomTableView - Cell Background Image

Cell Background Image – Top and Bottom images are with rounded corners

The UITableViewCell class allows developers to assign a custom background view using the “backgroundView:” method. To assign your own custom background image, we can create an UIImageView object with the background image and set it as the background view of the cell. Add the following code to the “cellForRowAtIndexPath:” method:

1
2
3
4
5
6
    // Assign our own background image for the cell
UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];

UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
cell.backgroundView = cellBackgroundView;

There is one thing missing. We haven’t implemented the “cellBackgroundForRowAtIndexPath:” method. As explained before, we have three types of background image. The top and bottom cells are assigned with different background images that are differed from the rest of the cells. So we create the “cellBackgroundForRowAtIndexPath:” method to determine the background image to assign. Add the following code before the “cellForRowAtIndexPath:” method:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
– (UIImage *)cellBackgroundForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger rowCount = [self tableView:[self tableView] numberOfRowsInSection:0];
NSInteger rowIndex = indexPath.row;
UIImage *background = nil;

if (rowIndex == 0) {
background = [UIImage imageNamed:@”cell_top.png”];
} else if (rowIndex == rowCount – 1) {
background = [UIImage imageNamed:@”cell_bottom.png”];
} else {
background = [UIImage imageNamed:@”cell_middle.png”];
}

return background;
}

For the first row of the cell (i.e. rowIndex == 0), the method returns the top cell image. If it’s the last table cell (i.e. rowIndex == rowCount – 1), the method returns the bottom cell image. For the rest of table cell, it simply returns the middle cell image.

Lastly, add the following line of code in the “viewDidLoad” method of RecipeViewController.m. This tells the table cell not to show the separator as our own cell images already come with the separator.

1
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

Compile and run the app. You should end up with an app like this:

CustomTableView - Styled Table View Cell

Recipe book app with custom background cell image

Styling the Table View Background

The app looks much better, right? Let’s make it even better by assigning a background image to the view. Add the following code to “viewDidLoad” method of RecipeViewController.m:

1
2
    self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@”common_bg”]];
self.tableView.backgroundColor = [UIColor clearColor];

As the RecipeViewController is a subclass of UITableViewController, we use “self.parentViewController” to access its parent view, followed by assigning the background. By default, the table view is displayed in white. We set its color to transparent so as not to block out the background of the parent view.

Before you run the app, we’d like to make one more change. The table view is now very close to the navigation bar. You may want to add padding at the top of the table view. To add padding, you can use the contentInset property to specify a buffer area around the content of the view. The contentInset property is a UIEdgeInsets struct with the fields top, bottom, left, right. Let’s add the following code in “viewDidLoad”:

1
2
    UIEdgeInsets inset = UIEdgeInsetsMake(5, 0, 0, 0);
self.tableView.contentInset = inset;

The above code results in an additional buffer area that is 5 pixels at the top of the table view. Compile and run the app again. Your app should now be customized with padding and our own background image:

CustomTableView - Final app

Recipe book app in better style

What’s Coming Next

Again, I hope you enjoy the tutorial and find it useful. For your complete reference, you can download the final Xcode project here.

Earlier, we already showed you how to customize the tab bar and navigation bar. Combining with this tutorial, you should be able to make your table-based app more attractive. Later, we’ll see how to style other UI elements. Stay tuned.

 

Copy from: http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/

 
Leave a comment

Posted by on April 19, 2013 in iOS, Mobile Development

 

Fix error: Undefined symbols for architecture i386: “_OBJC_CLASS_$_ASIHTTPRequest”, referenced from:

By Sochinda Tith

When we have setup ASIHTTPRequest as bellow:

http://allseeing-i.com/ASIHTTPRequest/Setup-instructions

 

You will get error:

Undefined symbols for architecture i386:   “_OBJC_CLASS_$_ASIHTTPRequest”, referenced from:….

Please go to Traget Project -> Build Phases -> Compile Source

and add all bellow with Compiler Flage : -fno-objc-arc

ASIHTTPRequest.m
ASIAuthenticationDialog.m
ASIDataCompressor.m
ASIDataDecompressor.m
ASIInputStream.m
Reachability.m

Screen Shot 2013-03-21 at 4.46.34 PM

 

 
Leave a comment

Posted by on March 21, 2013 in iOS, Mobile Development

 

How to Write an iOS App That Uses a Web Service

By: raywenderlich

As an iOS developer, you often need to use a web service from your app.

Sometimes you need to use a web service that someone else has written, and sometimes you need to use one of your own!

In this tutorial, you’ll get hands-one experience with using web services, by writing an iOS app that communicates with a simple web service that allows you to redeem promo codes to unlock extra content.

This tutorial is the second and final part of a two part series on custom web services. If you are curious how to develop the web service yourself, check out the first part of the series for full details!

You don’t necessarily have to set up the web service yourself for this tutorial – you can use the one I’ve already set up if you’d like.

This tutorial assumes you have basic familiarity with programming for iOS. If you are new to iOS development, you may wish to check out some of the other tutorials on this site first.

The Choice

This tutorial requires you to create a new View-based application and integrate three frameworks into it: the JSON framework, ASIHTTPRequest, and MBProgressHUD. You also have to make a basic UI for the app so the user can enter in a code to redeem.

But that’s a lot of work, so I thought we’d start this tutorial out with a choice. Are you like this guy?

If so, then just download this starter project with the libraries pre-integrated and the UI pre-made and skip the next two sections :]

Otherwise, read on DIYer! :]

Do It Yourself!

If you want to create everything yourself, start up Xcode and go to File\New\New Project, select iOS\Application\View-based Application, and click Next. Enter PromoTest for the Product Name, click Next, and save it somewhere.

To add the JSON framework, first download it from its github page. Once you have it downloaded, right click your PromoTest project entry in groups and files, select New Group, and name the new group JSON. Then drag all of the files from the JSON\Classes directory (JSON.h and several others) into the new JSON group. Make sure “Copy items into destination group’s folder (if needed)” is selected, and click Finish.

To add ASIHTTPRequest, first download it. Once you have it downloaded, right click your PromoTest project entry in groups and files, select New Group, and name the new group ASIHTTPRequest. Then drag all of the files from the ASIHTTPRequest\Classes directory (ASIAuthenticationDialog.h and several others, but IMPORTANT! don’t add the subfolders such as ASIWebPageRequest, CloudFiles, S3, and Tests.) into the new ASIHTTPRequest group. Make sure “Copy items into destination group’s folder (if needed)” is selected, and click Finish.

Also repeat this for the two files in ASIHTTPRequest\External\Reachability, as these are dependencies of the project.

To add MBProgressHUD, first download it. Once you have it downloaded, right click your PromoTest project entry in groups and files, select New Group, and name the new group MBProgressHUD. Then drag MBProgressHUD.h and MBProgressHUD.m into the new MBProressHUD group. Make sure “Copy items into destination group’s folder (if needed)” is selected, and click Finish.

The last step is you need to link your project against a few required frameworks. To do this, click on your PromoTest project entry in Groups & Files, click the PromoTest target, choose the Build Phases tab, and expand the Link Binary with Libraries section. Click the plus button in this section, and choose CFNetwork.framework. Then repeat this for SystemConfiguration.framework, MobileCoreServices.framework, and libz.1.2.3.dylib.

Framework Dependencies in Xcode 4

Compile your project just to make sure you’re good so far, and now we’re back to the fun stuff!

Implementing the Interface

Let’s make a quick and simple interface to test this web service. As a refresher, the web service takes three parameters:

  1. rw_app_id: The unique identifier for the app. If you’ve been following along with the previous tutorial, there should be only one entry so far, App ID #1.
  2. code: The code to attempt to redeem. This should be a string that’s entered by the user.
  3. device_id: The device ID that is attempting to redeem this code. We can get this with an easy API call.

So basically, all we need is a text field for the user to enter the code (they’ll tap “Go” on the keyboard to start the redemption process), a label for the text field, and a text view to write the result out to.

So click on PromoTestViewController.xib, bring up the Object library by selecting the third tab in the View toolbar (Utilities) and selecting the third tab in the library toolbar (Object library), as shown in the screenshot below.

Object Library in Xcode 4

From the Object library, drag a UILabel, UITextField, UITextView into the main view. Double click the UILabel and change the text to read “Enter promo code:”. Then double click the text view and delete all the text inside, and optionally change the background color of the UITextField to clear in the Attributes Inspector.

You also may find it useful to go to Editor\Canvas\Show Bounds Rectangles so you can see the bounds of the text view.

At this point your layout should look similar to the screenshot below:

Interface Builder Layout in Xcode 4

Next, you need to set the File’s Owner as the Text Field’s delegate so you can get a callback when the return button is clicked on the keyboard. To do this, control-click on the Text Field, and drag a line from the delegate entry to the File’s Owner.

Also, you need to connect the text view to an outlet so you can set it later. To do this in the cool new Xcode 4 way, first turn on the Assistant Editor (the second button in the Editor tab) and make it show up on the bottom with View\Assistant Layout\Assistant Editors on Bottom. Make sure it’s set to Automatic and that PromoTestViewController.h is visible.

Then select the Text View and control-drag a line from the text view down to right above the @end keyword, set Connection tou Outlet, the Name to textView, and click Connect, as you can see in the screenshot below.

Connecting an Outlet with the Assistant Editor in Xcode 4

At this point Xcode will automatically create a textView property and instance variable for you.

Finally, open PromoTestViewController.h and mark the class as implenting UITextFieldDelegate as follows:

@interface PromoTestViewController : UIViewController <UITextFieldDelegate> {

Then switch to PromoTestViewController.m and implement textFieldShouldReturn as follows:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    NSLog(@"Want to redeem: %@", textField.text);
    return TRUE;
}

Compile and run your app, tap the text field, enter a code, and tap the return button, and you should see a message in your console output similar to the following:

2011-03-28 15:37:05.342 PromoTest[44350:207] Want to redeem: test

OK – all the setup is done, and you’re ready to start communicating with the web service!

Communicating with the Web Service

If you’ve grabbed the starter project and skipped ahead, here’s where you should pick back up! Otherwise, good progress so far DIYer! :]

To redeem the promo code, we need to to send a POST to our web service’s with three parameters: the app id, the code to redeem, and the device ID.

The good news is sending a POST is extremely easy with ASIHTTPRequest. You simply:

  • Create a new instance of ASIFormDataRequest and specify the URL
  • Use the setPostValue method to specify each parameter
  • Set the view controller as the delegate of the request, and then call startAsynchronous to start the request in the background
  • When it’s done, either requestFinished or requestFailed will be called on the view controller
  • requestFinished will be called even if the web server responds with an error code. So there you need to check for success or failure…
  • And if success, parse the response string as JSON!

Let’s see what this looks like. First add the following imports to the top of the file:

#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "JSON.h"

Then replace textFieldShouldReturn with the following:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    NSLog(@"Want to redeem: %@", textField.text);

    // Get device unique ID
    UIDevice *device = [UIDevice currentDevice];
    NSString *uniqueIdentifier = [device uniqueIdentifier];

    // Start request
    NSString *code = textField.text;
    NSURL *url = [NSURL URLWithString:@"http://www.wildfables.com/promos/"];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:@"1" forKey:@"rw_app_id"];
    [request setPostValue:code forKey:@"code"];
    [request setPostValue:uniqueIdentifier forKey:@"device_id"];
    [request setDelegate:self];
    [request startAsynchronous];

    // Hide keyword
    [textField resignFirstResponder];

    // Clear text field
    textView.text = @"";    

    return TRUE;
}

If you’ve set up your own web service following the previous tutorial, you should replace the URL with wherever you put your web service.

As you can see – very simple, following the steps outlined above. Finally, implement the requestFinished and requestFailed callbacks to log out the results:

- (void)requestFinished:(ASIHTTPRequest *)request
{    

    if (request.responseStatusCode == 400) {
        textView.text = @"Invalid code";        
    } else if (request.responseStatusCode == 403) {
        textView.text = @"Code already used";
    } else if (request.responseStatusCode == 200) {
        NSString *responseString = [request responseString];
        NSDictionary *responseDict = [responseString JSONValue];
        NSString *unlockCode = [responseDict objectForKey:@"unlock_code"];

        if ([unlockCode compare:@"com.razeware.test.unlock.cake"] == NSOrderedSame) {
            textView.text = @"The cake is a lie!";
        } else {        
            textView.text = [NSString stringWithFormat:@"Received unexpected unlock code: %@", unlockCode];
        }

    } else {
        textView.text = @"Unexpected error";
    }

}

- (void)requestFailed:(ASIHTTPRequest *)request
{    
    NSError *error = [request error];
    textView.text = error.localizedDescription;
}

This simply checks for the error codes that we expect from our web service, and prints a message for each. Or if it’s succcessful, parses the JSON with the JSON framework, and checks the unlock code. Here is where you could grant the user with whatever special content you might want to give them in your app.

Compile and run your project, and you should see something like the following:

The cake is a lie!

Adding a Progress HUD

The app works so far, but when you’re running a task in the background like this it’s often nice to let the user know what’s going on. This is nice and easy with MBProgressHUD, so let’s quickly add it in:

// Add at the top of the file
#import "MBProgressHUD.h"

// Add right before return TRUE in textFieldShouldReturn
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Redeeming code...";

// Add at start of requestFinished AND requestFailed
[MBProgressHUD hideHUDForView:self.view animated:YES];

Compile and run your code, and this time a nice progress indicator should appear while the request is running!

Promo Code System: My Experience

Now as promised, I’d like to share my experience using this promo code system in Wild Fables with you guys!

I set up two codes for Wild Fables – one to unlock a single fable (of the user’s choice), and one to unlock all fables. I set up the first one so I could give out codes to friends & family to give them a little extra taste of Wild Fables, and I set up the second one so I’d have a way to give out full access to Wild Fables to professional app reviewers.

One of my favorite things about this system is it allows for unlimited codes. Which was great as 100 people used a code I gave out on Twitter alone (thanks again for checking it out and all the RTs guys, you rule!)!

I also put some codes in some threads on some various iOS forums, our mailing list for Razeware, our Facebook pages, etc. I made a separate code for each place I gave out the code, which is nice because it let me track where people actually cared about the post & used codes, and where people were more like the picture earlier in this tutorial ;]

People redeemed the codes most often on Twitter or the Cocos2D forums (which makes sense, as my friends such as yourself hang out there), then on the Razeware mailing list (which also makes sense, since if people subscribe to that they must be interested in our products). Forum-wise, Reddit came up on top, then the iPad ForumsMobileReadMacRumors, and TouchArcade were the best in that order.

Another amusing thing was sometimes I’d get emails from “reviewers” asking for a promo code to redeem my app, so of course I’d send them a custom code. But these “reviewers” would also include a pitch to try to get me to advertise on my site. Looking at the redemption table, I can see that several of them didn’t even bother to redeem the code, so I guess their real reason to email me was to get ad revenue, so beware! :]

As far as drawbacks go, as some people noticed the “unlock” is implemented basically by saving data to the file system, so it doesn’t work across all devices like in-app purchases do. You can implement this by creating a login system or such, but that was overkill for what I wanted to do.

So that’s it for my experience! Let me know if you have any further questions.

Where To Go From Here?

Here is a sample project with all of the code we’ve developed in the above tutorial.

Now that you have first-hand experience creating both a simple web service and an app that communicates with it from scratch, you can take the ideas here and create your own web services that do anything you need for your app!

If you have any questions about communicating with a web service from an iPhone app, questions about the promo code system, or advice for others in this matter, please join the forum discussion below!

 

Copy from: http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service

 
Leave a comment

Posted by on March 20, 2013 in iOS, Mobile Development

 

Make an IPA on XCode

By: soheilpro

Here’s how you can make an IPA in XCode 4.3:

To Disable Code Signing:

  1. Go to /Applications.
  2. Right click on XCode and select ‘Show Package Contents’.
  3. CopyContents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist to your desktop. (Make sure to actually copy and paste. No drag and drop)
  4. Open it and under DefaultProperties set CODE_SIGNING_REQUIRED to NO.
  5. Copy it back and replace the original file.
  6. Restart XCode.
  7. Open your project.
  8. In Project Navigator select your project and open Build Settings section of your porject (and not any particular target)
  9. Under Code Signing find Code Signing Identity and for both Debug and Release modes setAny iOS SKD to Don't Code Sign.
  10. Now you should be able to build your project without any errors.

To make an IPA:

  1. In ‘Project Navigator’ select Products
  2. Right click on [NameOfYourProject].app and select ‘Show in Finder’.
  3. Create a folder and name it Payload
  4. Move [NameOfYourProject].app to Payload.
  5. Compress Payload and rename it to [NameOfYourProject].ipa

 

You should be able to get an IPA by clicking ‘Distribute…’ in Organizer->Archives, and choosing to ‘Save for Enterprise or Ad-Hoc Deployment’.

 

Refferenced by: http://stackoverflow.com/questions/9350972/how-to-make-an-ipa-on-xcode-4-3

 
Leave a comment

Posted by on March 13, 2013 in iOS, Mobile Development

 

How to SplashScreen Display in the iPhone

By:  Sushant

In this application we will se how to display SplashScreen. When user run the application, it will show the splashScreen after some time it will automatically remove from the Screen. Basically this is the very simple application. So just have a look, how it will be worked.

In this application we will se  how to display SplashScreen. When user run the application, it will show the splashScreen after some time it will automatically remove from the Screen. Basically this is the very simple application. So just have a look, how it will be worked.

Step 1: Create a View base application using template. Give the application name “DisplaySplashScreen”.

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: Expand classes and notice Interface Builder created the DisplaySplashScreenViewController class for you. Expand Resources and notice the template generated a separate nib, DisplaySplashScreenViewController.xib, for the “DisplaySplashScreen”.

Step 4: We need to add the resource file called as “themes.png” into the resource folder. Select resources and add files existing sources and select the themes.png.

Step 5: In the DisplaySplashScreen.h file, we have added UIView for display the screen and mention two methods. So make the following changes:

@interface DisplaySplashSceenViewController : UIViewController {
IBOutlet UIView *displaySplash;
}
-(void)displayScreen;
-(void)removeScreen;

Step 6: Double click your DisplaySplashScreen.xib file open it to the Interface Builder. Drag the view from the library and place it to the Main Window(See the figure1 below). Open the second view icon from the MainWindow,drag the image view from the library and place it to the view window,select the view and bring up Attribute Inspector select the image “themes.png”. Select the File’s Owner icon from the MainWindow and bring up Connection Inspector, drag from the displayScreen to the last view icon (See the figure2 below) and connect File’s Owner icon to the view (See the figure3 below). Now save it , close it and go back to the Xcode.

Figure1: MainWindow

Figure 2: Connection Between displayScreen and View icon.

Figure 3: Connection Between File’s Owner icon to the View icon.

Step 7: Open the DisplaySplashScreen.m file, you will see here splash will be displayed 4 to 5 sec in the main screen after that splash screen will be removed from the Main Screen. So make the following changes:

-(void)displayScreen
{
UIViewController *displayViewController=[[UIViewController alloc] init];
displayViewController.view = displaySplash;
[self presentModalViewController:displayViewController animated:NO];
[self performSelector:@selector(removeScreen) withObject:nil afterDelay:4.0];
}-(void)removeScreen
{
[[self modalViewController] dismissModalViewControllerAnimated:YES];
}

Step  8: In the DisplaySplashScreenAppDelegate.m file make the following changes in the file.

– (void)applicationDidFinishLaunching:(UIApplication *)application {[window addSubview:viewController.view];
[window makeKeyAndVisible];
[viewController displayScreen];
}

Step 9: Now compile and run the application in the Simulator.

You can downloaded SourceCode from here DisplaySplashSceen 2

Referenced by: http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-splashscreen-display-in-the-iphone/

 
Leave a comment

Posted by on August 31, 2012 in iOS