Alert View of Table Type in iPhone

Introduction

In this article I will create an Empty View application. Here I will implement am alert view of a table type. For this here we write code in the appdelegate.m Objective-C class.

To understand it we use the following.

Step 1

Open XCode by double-clicking on it.

Step 2

Create a New XCode Project by clicking on it.

Step 3

Now Select Empty View Application and click on Next.

Step 4

Now provide your Product Name and Company Identifier.

Step 5

Select the location where you want to save your project and click on Create.

Step 6

Now here we write the code.

AppDelegate.h

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface testviewAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UITableView *table;
@property (strong, nonatomic) UIWindow *window;
@end

AppDelegate.m

#import "testviewAppDelegate.h"
@implementation testviewAppDelegate
@synthesize table,array;
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Table" message:@"click for submission \n\n\n\n "delegate:self cancelButtonTitle:@"click for submission"
otherButtonTitles:nil];
array = [[NSMutableArray alloc]init];
[array addObject:@"Sun"];
[array addObject:@"Mon"];
[array addObject:@"Tues"];
[array addObject:@"Sun"];
[array addObject:@"Mon"];
[array addObject:@"Tues"];
table = [[UITableView alloc]initWithFrame:CGRectMake(10, 40, 264, 120)];
[alert addSubview:table];
[alert show];
[table release];
[alert release];
[self.window addSubview:alert];
[self.window makeKeyAndVisible];
return YES;
}
@end

Step 7

Finally we click on the run button to show the output.

Step 8

Output 1 in iPhone:

Table-alert-view-in-iPhone.png

Up Next
    Ebook Download
    View all
    Learn
    View all