我想一個過渡效果添加到我的幻燈片:這裏是我的代碼添加在幻燈片過渡效果
- (void)viewDidLoad
{
[super viewDidLoad];
photos = [[NSMutableArray alloc] init];
NSXMLParser *photoParser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL
URLWithString:@"http://localhost/index.xml"]];
[photoParser setDelegate:(id)self];
[photoParser parse];
currentImage = 0;
NSURL *imageURL = [NSURL URLWithString:[photos objectAtIndex:0]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
[imgView setImage:[UIImage imageWithData:imageData]];
timer = [NSTimer scheduledTimerWithTimeInterval: 0.5
target: self
selector: @selector(handleTimer:)
userInfo: nil
repeats: YES];
}
- (void) handleTimer: (NSTimer *) timer {
currentImage++;
if (currentImage >= photos.count)
currentImage = 0;
NSURL *imageURL = [NSURL URLWithString:[photos objectAtIndex:currentImage]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
[imgView setImage:[UIImage imageWithData:imageData]];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"photo"]) {
[photos addObject:[attributeDict objectForKey:@"url"]];
}
}
我想我應該用
[UIView transitionFromView:currentView toView:nextView duration:1.0
options:UIViewAnimationOptionTransitionCrossDissolve completion:nil];
,但我也不怎麼以填充transitionFRomView:和toView:字段。我只有一個視圖
感謝您的幫助
我現在無法測試,但我會盡快完成,我會通知您。感謝您的幫助 – Enzoses 2012-03-17 23:18:59