In this tutorial we will see how can we use model view controller in Ipad. This is the view Based based application. Here are some steps for it…
1. Open the xcode & choose "File->New Project".
2. Select "Application" from left menu and then "View-based Application".
3.Name your project as "IpadModalViewController" and save the project.
4.Now just select "IpadModalViewControllerViewController.h" file from left menu for define a UItableView . Set the property for Uitable View , define a method toolbarItemTapped as IBAction.
#import <UIKit/UIKit.h>
@interface IpadModalViewControllerViewController : UIViewController {
UIPopoverController *popoverController;
IBOutlet UITableView *table;
NSArray *Array;
}
@property(nonatomic,retain)UIPopoverController *popoverController;
-(IBAction)toolbarItemTapped:(id)sender;
@end
5. Now select "IpadModalViewControllerViewController.m" file from menu for implementation.
#import "IpadModalViewControllerViewController.h"
#import "NextView.h"
@implementation IpadModalViewControllerViewController
@synthesize popoverController;
-(IBAction)toolbarItemTapped:(id)sender
{
NextView* content = [[NextView alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.popoverController = aPopover;
[aPopover release];
[self.popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return [Array count];}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell setText:[ Array objectAtIndex:indexPath.row]];
return cell;
}
- (void)viewDidLoad {
[super viewDidLoad];
Array=[[NSArray alloc]initWithObjects:@"kamal",@"samar",@"dharamendra",@"suraj",@"tapan",nil];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
6. Now double click on "IpadModalViewControllerViewController.xib" from Resource folder for open it.
7. On the view window drag the UITableView from library . Then link the UITableView to the File's Owner. And link the button to IBActon method.
8. Then Quit and Save the Interface Builder.
9. Now you are ready for click on "Build & Go" button.
Now you can see the output in iphone simulator .
Fell out of bed feleing down. This has brightened my day!
Bovta2 tjygrnkkdcmi
pPqNl0 , [url=http://hdlsldwlmyuc.com/]hdlsldwlmyuc[/url], [link=http://rhiyhmlrfhwp.com/]rhiyhmlrfhwp[/link], http://evlkcobaewdz.com/
http://www.shopdiazepamfast.com/ - buy valium online cheap buy valium no rx generic valium online buy valium generic http://www.shopdiazepamfast.com/
(4) Responses to this post