UITabbar Application coding part

Thing Music Code and details.....

UITab Bar Application:(default Five tab is visble on the screen )
1.File --->new -->uitabbar Application
2.go to MainWindow.Xib and delete the default first and second view controller
3.Track to insert uinavigation controller like the (based on the reqirements )



4.Add new files follows....

new file-->uiviewcontroller subclass--->next (give file name what u want)

5.Go to MainWindow.xib
a. To set the navigationbar color like


b. To push the custom class


c.To set the tab bar item images and name

d.To add the Tabbar button and set the button action


- (void)viewWillAppear:(BOOL)animated

{
NSLog(@"song page");
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; //To hide the status Bar
[super viewWillAppear:animated];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImage *butImage = [[UIImage imageNamed:@"nowplaying.png"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
[button setBackgroundImage:butImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(goToNowPlaying:) forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0, 97, 28);
UIBarButtonItem *myButton = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
self.navigationItem.rightBarButtonItem = myButton;
//[self.myTableView reloadData];
}


-(IBAction)goToNowPlaying:(id)sendor
{
//[appDelegate.audioPlayer1 stop];
Player *anotherViewController = [[Player alloc] initWithNibName:@"Player" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}


1.To add the table view and connect the delegate and data source

and push the particular row to xib



- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = FALSE;
NSIndexPath* selection = [self.myTableView indexPathForSelectedRow];
if (selection)
[self.myTableView deselectRowAtIndexPath:selection animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}





#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 7;
}


- (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.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
// if(indexPath.row == 0)
// cell.textLabel.text = @"Gig Map";
if(indexPath.row == 0)
cell.textLabel.text = @"Album Info";
// else if(indexPath.row == 1)
// cell.textLabel.text = @"Share";
else if(indexPath.row == 1)
cell.textLabel.text = @"About Purplenote";
else if(indexPath.row == 2)
cell.textLabel.text = @"Policy";
else if(indexPath.row == 3)
cell.textLabel.text = @"Contact Us";
else if(indexPath.row == 4)
cell.textLabel.text = @"Credits";
else if(indexPath.row == 5)
cell.textLabel.text = @"Feedback";
else if(indexPath.row == 6)
cell.textLabel.text = @"Support";
return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// if(indexPath.row == 0)
// {
// Gig_map *gig = [[Gig_map alloc] init];
// [self.navigationController pushViewController:gig animated:YES];
// // [aboutplayin release];
//
// /* AudioPlayerView *anotherViewController = [[AudioPlayerView alloc] initWithNibName:@"AudioPlayerView" bundle:nil];
// [[self navigationController] pushViewController:anotherViewController animated:YES];
// //[anotherViewController release];
// */
// }
//
if(indexPath.row == 0)
{
MovieInfo *anotherViewController = [[MovieInfo alloc] initWithNibName:@"MovieInfo" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
// else if(indexPath.row == 1)
// {
// UITabBarController *tabBarController = (UITabBarController *)[[[UIApplication sharedApplication] delegate] tabBarController];
//
// UINavigationController *otherNavController = (UINavigationController *)[[tabBarController viewControllers] objectAtIndex:4];
//
// Share *anotherViewController = [[Share alloc] initWithNibName:@"Share" bundle:nil];
//
// [otherNavController pushViewController:anotherViewController animated:YES];
//
// tabBarController.selectedIndex = 4;
// }
else if(indexPath.row == 1)
{
AboutUs *anotherViewController = [[AboutUs alloc] initWithNibName:@"AboutUs" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
else if(indexPath.row == 2)
{
Policy *anotherViewController = [[Policy alloc] initWithNibName:@"Policy" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
else if(indexPath.row == 3)
{
ContactUs *anotherViewController = [[ContactUs alloc] initWithNibName:@"ContactUs" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
else if(indexPath.row == 4)
{
Credtis *anotherViewController = [[Credtis alloc] initWithNibName:@"Credtis" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
else if(indexPath.row == 5)
{
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
mailComposer.navigationBar.tintColor = [UIColor colorWithRed:67.0f/255.0f green:18.0f/255.0f blue:73.0f/255.0f alpha:1.0f];
if ([MFMailComposeViewController canSendMail]) {
[mailComposer setToRecipients:[NSArray arrayWithObjects:@"info@purplenote.in",nil]];
[mailComposer setSubject:@"Feedback"];
[mailComposer setMessageBody:@" " isHTML:NO];
mailComposer.navigationBar.tintColor = [UIColor colorWithRed:67.0f/255.0f green:18.0f/255.0f blue:73.0f/255.0f alpha:1.0f];
[self presentModalViewController:mailComposer animated:YES];
}
[mailComposer release];
}
else if(indexPath.row == 6)
{
Support *anotherViewController = [[Support alloc] initWithNibName:@"Support" bundle:nil];
[[self navigationController] pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}

- (void)dealloc {
[super dealloc];
[myTableView release];
}


@end

No comments:

Post a Comment