[ios] Added additional bookmarks controllers

This commit is contained in:
Alex Zolotarev 2012-05-08 15:36:45 +03:00 committed by Alex Zolotarev
parent f8aa9c1632
commit e1851e1123
4 changed files with 118 additions and 102 deletions

View file

@ -0,0 +1,5 @@
#import <UIKit/UIKit.h>
@interface AddBookmarkVC : UITableViewController
@end

View file

@ -0,0 +1,72 @@
#import "AddBookmarkVC.h"
@implementation AddBookmarkVC
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self)
{
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(onAddClicked)];
self.title = NSLocalizedString(@"Add Bookmark", @"Add bookmark dialog title");
}
return self;
}
- (void)onAddClicked:(id)sender
{
}
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:YES];
[super viewWillAppear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"AddBMCell"];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"AddBMCell"] autorelease];
switch (indexPath.row)
{
case 0:
cell.textLabel.text = NSLocalizedString(@"Name", @"Add bookmark dialog - bookmark name");
cell.detailTextLabel.text = @"Washington";
break;
case 1:
cell.textLabel.text = NSLocalizedString(@"Set", @"Add bookmark dialog - bookmark set");
cell.detailTextLabel.text = @"Default";
break;
case 2:
cell.textLabel.text = NSLocalizedString(@"Color", @"Add bookmark dialog - bookmark color");
cell.detailTextLabel.text = @"Blue";
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];
}
@end

View file

@ -1,13 +1,7 @@
//
// PlacePageVC.h
// Maps
//
// Created by Alexander Zolotarev on 19/04/2012.
// Copyright (c) 2012 MapsWithMe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PlacePageVC : UITableViewController
{
BOOL m_hideNavBar;
}
@end

View file

@ -1,128 +1,73 @@
//
// PlacePageVC.m
// Maps
//
// Created by Alexander Zolotarev on 19/04/2012.
// Copyright (c) 2012 MapsWithMe. All rights reserved.
//
#import "PlacePageVC.h"
@interface PlacePageVC ()
@end
#import "AddBookmarkVC.h"
@implementation PlacePageVC
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
self = [super initWithStyle:style];
if (self)
{
self.title = NSLocalizedString(@"Place Page", @"Add bookmark dialog title");
}
return self;
}
- (void)viewDidLoad
- (void)viewWillAppear:(BOOL)animated
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
m_hideNavBar = YES;
[self.navigationController setNavigationBarHidden:NO animated:YES];
[super viewWillAppear:animated];
}
- (void)viewDidUnload
- (void)viewWillDisappear:(BOOL)animated
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
if (m_hideNavBar)
[self.navigationController setNavigationBarHidden:YES animated:YES];
[super viewWillDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
return cell;
UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease];
cell.textLabel.textAlignment = UITextAlignmentCenter;
if (indexPath.section == 0)
cell.textLabel.text = NSLocalizedString(@"Add To Bookmarks", @"Place Page - Add To Bookmarks button");
else
cell.textLabel.text = NSLocalizedString(@"Remove Pin", @"Place Page - Remove Pin button");
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
[[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];
if (indexPath.section == 0)
{
AddBookmarkVC * addVC = [[AddBookmarkVC alloc] initWithStyle:UITableViewStyleGrouped];
m_hideNavBar = NO;
[self.navigationController pushViewController:addVC animated:YES];
[addVC release];
}
else
{
[self.navigationController popViewControllerAnimated:YES];
}
}
@end