posted by 프띠버리 2013. 9. 16. 16:04

BeautyOfKoreaAppDelegate.h

#import <UIKit/UIKit.h>


@interface BeautyOfKoreaAppDelegate : UIResponder <UIApplicationDelegate>

{

    UIWindow *window;

    UINavigationController *navigationController;

}


@property (strong, nonatomic) IBOutlet UIWindow *window;

@property (strong, nonatomic) IBOutlet UINavigationController *navigationController;


@end




BeautyOfKoreaAppDelegate.m

#import "BeautyOfKoreaAppDelegate.h"

#import "RootViewController.h"


@implementation BeautyOfKoreaAppDelegate


@synthesize window;

@synthesize navigationController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

//    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.

//    self.window.backgroundColor = [UIColor whiteColor];

    [self.window addSubview:[navigationController view]];

    [self.window makeKeyAndVisible];

    return YES;

}




RootViewController.h

#import <UIKit/UIKit.h>


@class ContentViewController;

@interface RootViewController : UIViewController

{

    IBOutlet UIButton *btnMenu1;

    IBOutlet UIButton *btnMenu2;

    IBOutlet UIButton *btnMenu3;

    IBOutlet UIButton *btnMenu4;

    IBOutlet UIButton *btnMenu5;

    IBOutlet UIButton *btnMenu6;

    IBOutlet UIImageView *ivBackground;

    IBOutlet UIImageView *ivTitle;

    ContentViewController *contentViewController;

}


@property(nonatomic, retain) IBOutlet UIButton *btnMenu1;

@property(nonatomic, retain) IBOutlet UIButton *btnMenu2;

@property(nonatomic, retain) IBOutlet UIButton *btnMenu3;

@property(nonatomic, retain) IBOutlet UIButton *btnMenu4;

@property(nonatomic, retain) IBOutlet UIButton *btnMenu5;

@property(nonatomic, retain) IBOutlet UIButton *btnMenu6;

@property(nonatomic, retain) IBOutlet UIImageView *ivBackground;

@property(nonatomic, retain) IBOutlet UIImageView *ivTitle;


-(IBAction)btnMenu1Touched;

-(IBAction)btnMenu2Touched;

-(IBAction)btnMenu3Touched;

-(IBAction)btnMenu4Touched;

-(IBAction)btnMenu5Touched;

-(IBAction)btnMenu6Touched;


@end




RootViewController.m


#import "RootViewController.h"

#import "ContentViewController.h"

#import "MapViewController.h"


@interface RootViewController ()


@end


@implementation RootViewController

@synthesize btnMenu1;

@synthesize btnMenu2;

@synthesize btnMenu3;

@synthesize btnMenu4;

@synthesize btnMenu5;

@synthesize btnMenu6;

@synthesize ivBackground;

@synthesize ivTitle;


-(IBAction)btnMenu1Touched

{

    contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    contentViewController.currentMenu = 1;

    [self.navigationController pushViewController:contentViewController animated:YES];

}


-(IBAction)btnMenu2Touched

{

    contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    contentViewController.currentMenu = 2;

    [self.navigationController pushViewController:contentViewController animated:YES];

    

}


-(IBAction)btnMenu3Touched

{

    contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    contentViewController.currentMenu = 3;

    [self.navigationController pushViewController:contentViewController animated:YES];

    

}


-(IBAction)btnMenu4Touched

{

    contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    contentViewController.currentMenu = 4;

    [self.navigationController pushViewController:contentViewController animated:YES];

    

}


-(IBAction)btnMenu5Touched

{

    contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    contentViewController.currentMenu = 5;

    [self.navigationController pushViewController:contentViewController animated:YES];

    

}


-(IBAction)btnMenu6Touched

{

    MapViewController *mapViewController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil];

    [self.navigationController pushViewController:mapViewController animated:YES];

}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end




GalleryViewController.h

#import <UIKit/UIKit.h>


@interface GalleryViewController : UIViewController

{

    IBOutlet UIButton *btnBack;

    IBOutlet UIScrollView *svContent;

    int currentMenu;

}


@property(assign) int currentMenu;

@property(nonatomic, retain) IBOutlet UIButton *btnBack;

@property(nonatomic, retain) IBOutlet UIScrollView *svContent;


-(IBAction)btnbackTouched;


@end




GalleryViewController.m

#import "GalleryViewController.h"

//#import "ContentViewController.h"


#define kScrollObjHeight 466.0

#define kScrollObjWidth 310.0

#define kNumPhotos 20


@interface GalleryViewController ()


@end


@implementation GalleryViewController

@synthesize currentMenu;

@synthesize btnBack;

@synthesize svContent;


-(IBAction)btnbackTouched

{

    [self.navigationController popViewControllerAnimated:YES];

}


- (void)layoutScrollImages

{

    UIImageView *view = nil;

    NSArray *subviews = [svContent subviews];

    

    CGFloat curXLoc = 0;

    for(view in subviews)

    {

        if([view isKindOfClass:[UIImageView class]] && view.tag > 0)

        {

            CGRect frame = view.frame;

            frame.origin = CGPointMake(curXLoc, 0);

            view.frame = frame;

            

            curXLoc += (kScrollObjWidth);

        }

    }

    [svContent setContentSize:CGSizeMake((kNumPhotos * kScrollObjWidth), [svContent bounds].size.height)];

}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    

    svContent.clipsToBounds = YES;

    svContent.scrollEnabled = YES;

    svContent.directionalLockEnabled = YES;

    svContent.pagingEnabled = YES;

    

    for(int i=1;i<=kNumPhotos;i++)

    {

        NSString *imageName;

        

        if(i<10)

        {

            imageName = [NSString stringWithFormat:@"photos_%d_0%d.jpg", currentMenu, i];

        }

        else

        {

            imageName = [NSString stringWithFormat:@"phptos_%d_%d.jpg", currentMenu, i];

        }

        UIImage *image = [UIImage imageNamed:imageName];

        UIImageView *imageView =[[UIImageView alloc] initWithImage:image];

        

        CGRect rect = imageView.frame;

        rect.size.height = kScrollObjHeight;

        rect.size.width = kScrollObjWidth;

        imageView.frame = rect;

        imageView.tag = i;

        [svContent addSubview:imageView];

    }

    [self layoutScrollImages];

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end




MapViewController.h


#import <UIKit/UIKit.h>

#import <MapKit/MapKit.h>

#import "LocationAnnotation.h"


@interface MapViewController : UIViewController<MKMapViewDelegate>

{

    IBOutlet UIButton *btnBack;

    IBOutlet MKMapView *myMapView;

    IBOutlet UISegmentedControl *mapType;

    

    LocationAnnotation *locationAnnotation;

    

}


@property(nonatomic, readonly) LocationAnnotation *locationAnnotation;

@property(nonatomic, retain) IBOutlet UIButton *btnBack;

@property (strong, nonatomic) IBOutlet MKMapView *myMapView;

@property(strong, nonatomic) IBOutlet UISegmentedControl *mapType;


-(IBAction)btnBackTouched;

-(IBAction)mapTypeChanged;


@end




MapViewController.m


#import "MapViewController.h"

#import "ContentViewController.h"

#import <CoreLocation/CoreLocation.h>

#import <MapKit/MKUserLocation.h>

#import <CoreLocation/CLLocation.h>


@interface MapViewController ()


@end


@implementation MapViewController

@synthesize btnBack;

@synthesize myMapView;

@synthesize mapType;

@synthesize locationAnnotation;


-(IBAction)mapTypeChanged

{

    if(mapType.selectedSegmentIndex == 0)

    {

        myMapView.mapType = MKMapTypeStandard;

    }

    else if(mapType.selectedSegmentIndex==1)

    {

        myMapView.mapType = MKMapTypeSatellite;

    }

    else if(mapType.selectedSegmentIndex==2)

    {

        myMapView.mapType = MKMapTypeHybrid;

    }

}


-(IBAction)btnBackTouched

{

    [self.navigationController popViewControllerAnimated:YES];    

}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

        [myMapView setShowsUserLocation:YES];

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    myMapView.showsUserLocation = NO;

    myMapView.mapType = MKMapTypeStandard;

    myMapView.delegate = self;

    

    CLLocationCoordinate2D location;

    

    location.latitude = 35.815586;

    location.longitude = 129.333587;

    

    locationAnnotation = [[LocationAnnotation alloc] initWithCoordinate:location];

    [locationAnnotation setCurrentTitle:@"불국사(佛國寺)"];

    [locationAnnotation setCurrentSubTitle:@"Bulguksa Temple"];

    

    [myMapView addAnnotation:locationAnnotation];

    

    location.latitude = 36.543294;

    location.longitude = 128.553402;

    

    locationAnnotation = [[LocationAnnotation alloc] initWithCoordinate:location];

    [locationAnnotation setCurrentTitle:@"병산서원(倂山書院)"];

    [locationAnnotation setCurrentSubTitle:@"Byungsan Seowon"];

    

    [myMapView addAnnotation:locationAnnotation];

    

    location.latitude = 36.575835;

    location.longitude = 128.527465;


    locationAnnotation = [[LocationAnnotation alloc] initWithCoordinate:location];

    [locationAnnotation setCurrentTitle:@"하회마을"];

    [locationAnnotation setCurrentSubTitle:@"Hahoe Village"];

    

    [myMapView addAnnotation:locationAnnotation];

    

    location.latitude = 37.033255;

    location.longitude = 128.689513;


    locationAnnotation = [[LocationAnnotation alloc] initWithCoordinate:location];

    [locationAnnotation setCurrentTitle:@"부석사(浮石寺)"];

    [locationAnnotation setCurrentSubTitle:@"Busoksa Temple"];

    

    [myMapView addAnnotation:locationAnnotation];

    

    location.latitude = 35.838133;

    location.longitude = 129.219276;


    locationAnnotation = [[LocationAnnotation alloc] initWithCoordinate:location];

    [locationAnnotation setCurrentTitle:@"첨성대(瞻星臺)"];

    [locationAnnotation setCurrentSubTitle:@"Cheomseongdae"];

    

    [myMapView addAnnotation:locationAnnotation];

    

    location.latitude = 36.256861;

    location.longitude = 128.716908;

    

    MKCoordinateRegion region;

    MKCoordinateSpan span;

    span.latitudeDelta = 1;

    span.longitudeDelta = 1;

    

    region.span = span;

    region.center = location;

    

    [myMapView setRegion:region animated:YES];

    [myMapView regionThatFits:region];

}


- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation

{

    MKAnnotationView *annView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];

    annView.canShowCallout = YES;

    

    UIButton *btnDetailInfo = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    btnDetailInfo.frame = CGRectMake(0, 0, 23, 23);

    btnDetailInfo.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

    btnDetailInfo.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

    

    annView.rightCalloutAccessoryView = btnDetailInfo;

    annView.image = [UIImage imageNamed:@"annotationIcon.png"];

    annView.canShowCallout = YES;

    

    return annView;

}


- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

{

    LocationAnnotation *temp = view.annotation;

    

    NSString *tit1 = @"병산서원(倂山書院)";

    NSString *tit2 = @"불국사(佛國寺)";

    NSString *tit3 = @"부석사(浮石寺)";

    NSString *tit4 = @"첨성대(瞻星臺)";

    NSString *tit5 = @"하회마을";

    

    ContentViewController *contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

    

    if(temp.title == tit1)

    {

        contentViewController.currentMenu = 1;

    }

    else if(temp.title == tit2)

    {

        contentViewController.currentMenu = 2;

    }

    else if(temp.title == tit3)

    {

        contentViewController.currentMenu = 3;

    }

    else if(temp.title == tit4)

    {

        contentViewController.currentMenu = 4;

    }

    else if(temp.title == tit5)

    {

        contentViewController.currentMenu = 5;

    }

    

    [self.navigationController pushViewController:contentViewController animated:YES];

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end




LocationAnnotation.h


#import <Foundation/Foundation.h>

#import <MapKit/MapKit.h>


@interface LocationAnnotation : NSObject <MKAnnotation>

{

    CLLocationCoordinate2D coordinate;

    

    NSString *currentSubTitle;

    NSString *currentTitle;

}


@property(nonatomic, readonly) CLLocationCoordinate2D coordinate;

@property(nonatomic, retain) NSString *currentTitle;

@property(nonatomic, retain) NSString *currentSubTitle;


- (NSString *)title;

- (NSString *)subtitle;


- (id)initWithCoordinate:(CLLocationCoordinate2D) c;


@end




LocationAnnotation.m

#import "LocationAnnotation.h"

#import <MapKit/MapKit.h>


@implementation LocationAnnotation


@synthesize coordinate;

@synthesize currentSubTitle;

@synthesize currentTitle;


- (NSString *)subtitle

{

    return currentSubTitle;

}


- (NSString *)title

{

    return currentTitle;

}


- (id)initWithCoordinate:(CLLocationCoordinate2D)c

{

    coordinate = c;

    return self;

}


@end