我正在制作一个包含旋转木马的 iPhone 应用程序。请任何人告诉我们如何对 Carousel 的选定图像执行操作。
- (void)carousel:(iCarousel *)crsl didSelectItemAtIndex:(NSInteger)index { }
我正在尝试实现这个但它没有给出正确的结果请任何人告诉这个正确的实现
谢谢
最佳答案
像这样设置iCarousel的DataSource和Delegate
然后在 .h 文件中为 iCarousel 设置 ViewController Delegate
#import <UIKit/UIKit.h>
#import "iCarousel.h"
@interface iCarouselViewController : UIViewController<iCarouselDataSource, iCarouselDelegate>
@property (strong, nonatomic) NSMutableArray *images;
@property (nonatomic, retain) IBOutlet iCarousel *carousel;
@end
然后在 .m 文件中像这样编写委托(delegate)方法 didSelectItemAtIndex
-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
UIImage * img = [images objectAtIndex:index];
ImageViewController *aImageViewController = [[ImageViewController alloc] initWithNibName:@"ImageViewController" bundle:nil];
aImageViewController.image = img; //this code is used to send image to another view not tested
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:aImageViewController];
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
//this code used for present second-view controller that display selected image
navigationController.topViewController.title = @"Greeting's";
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
}
关于ios - 如何在轮播中选择图像并转到 iPhone 中的下一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16954255/