- (IBAction)btnFilePress:(id)sender {

NSString *path = [[NSBundle mainBundle] pathForResource:@"Moviecountdownwithsound" ofType:@"mp4"];

if (path) {

MovieURL = [NSURL fileURLWithPath:path];

}

//MPMoviePlayerController *thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:MovieURL]; //ver 3.x

MPMoviePlayerViewController *thePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:MovieURL];

//thePlayer.scalingMode = MPMovieScalingModeAspectFit; //ver 3.x

thePlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

thePlayer.moviePlayer.shouldAutoplay = YES;

[thePlayer shouldAutorotateToInterfaceOrientation:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

//[thePlayer play]; //ver 3.x

[self.navigationController presentModalViewController:thePlayer animated:NO];

}


- (void)myMovieFinishedCallback:(NSNotification *)aNotification {

MPMoviePlayerController *thePlayer = [aNotification object];

[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

[thePlayer release];

}


- (IBAction)btnStreamPress:(id)sender {

NSString *path = @"http://movies.apple.com/media/us/iphone/2010/tours/apple-iphone4-design_video-us-20100607_r848-9cie.mov";


if (path) {

MovieURL = [NSURL URLWithString:path];

}

//MPMoviePlayerController *thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:MovieURL]; //ver 3.x

MPMoviePlayerViewController *thePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:MovieURL];

//thePlayer.scalingMode = MPMovieScalingModeAspectFit;  //ver 3.x

thePlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

thePlayer.moviePlayer.shouldAutoplay = YES;

[thePlayer shouldAutorotateToInterfaceOrientation:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

//[thePlayer play];  //ver 3.x

[self.navigationController presentModalViewController:thePlayer animated:NO];

}

신고

'Object-C' 카테고리의 다른 글

키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08

UIViewController <MKMapViewDelegate, MKReverseGeocoderDelegate> {

...

}


- (void)viewDidLoad {

MKCoordinateRegion seoulRegion;

CLLocationCoordinate2D center;

center.latitude = 37.47783;

center.longitude = 127.044060;

MKCoordinateSpan span;

span.latitudeDelta = 0.005;

span.longitudeDelta = 0.005;

seoulRegion.center = center;

seoulRegion.span = span;

mapView.region = seoulRegion;

NSMutableArray *annotations = [[NSMutableArray alloc] init];

CLLocationCoordinate2D coord2d = {37.47783,127.044060};

MyAnnotation *anno = [[MyAnnotation alloc] initWithCoords:coord2d name:@"name1"];

anno.title = @"title1";

anno.subtitle = @"subtitle1";

[annotations addObject:anno];

[anno release];

CLLocationCoordinate2D coord2d1 = {37.480783,127.046060};

MyAnnotation *anno1 = [[MyAnnotation alloc] initWithCoords:coord2d1 name:@"name2"];

anno1.title = @"title2";

anno1.subtitle = @"subtitle2";

[annotations addObject:anno1];

[anno1 release];

[mapView addAnnotations:annotations];

[annotations release];

[super viewDidLoad];

}


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

{

MKPinAnnotationView *annoView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];

annoView.animatesDrop = YES;

UIButton *addButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

annoView.rightCalloutAccessoryView = addButton;

[annoView setCanShowCallout:YES];

[annoView setSelected:YES animated:YES];

[annoView release];

return annoView;

}

신고

'Object-C' 카테고리의 다른 글

NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08
CoreData  (0) 2010.10.07

@synthesize xmlView, xmlData, xmlList, currentItem, xmlValue;


- (void)viewDidLoad {

self.xmlData = [[NSData alloc] init];

self.xmlList = [[NSMutableArray alloc] init];

self.xmlValue = [[NSMutableString alloc] init];

self.currentItem = [[NSMutableDictionary alloc] init];

NSString *path = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"xml"];

NSData *data = [[NSData alloc] initWithContentsOfFile:path];

self.xmlData = data;

NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.xmlData];

[parser setDelegate:self];

[parser parse];

[parser release];

[xmlView reloadData];

[super viewDidLoad];

}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict

{

if ([elementName isEqualToString:@"d:entry"]) {

elementType = etItem;

}

[self.xmlValue setString:@""];

}


- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string

{

if(elementType == etItem){

[xmlValue appendString:string];

}

}


- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName

{

if(elementType != etItem)

return;

if([elementName isEqualToString:@"d:entry"]){

[self.xmlList addObject:[NSDictionary dictionaryWithDictionary:self.currentItem]];

}

else if([elementName isEqualToString:@"d:index"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

else if([elementName isEqualToString:@"h1"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

else if([elementName isEqualToString:@"p"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

}

-(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];

}

NSUInteger row = [indexPath row];

NSDictionary *dt = [self.xmlList objectAtIndex:row];

cell.textLabel.text = [NSString stringWithFormat:@"%@-%@", [dt objectForKey:@"h1"], [dt objectForKey:@"p"]];

return cell;

}


신고

'Object-C' 카테고리의 다른 글

MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08
CoreData  (0) 2010.10.07
archiving  (0) 2010.10.07

+ Recent posts