ios - 如何在轮播中选择图像并转到 iPhone 中的下一个 View

标签 ios icarousel

我正在制作一个包含旋转木马的 iPhone 应用程序。请任何人告诉我们如何对 Carousel 的选定图像执行操作。

- (void)carousel:(iCarousel *)crsl didSelectItemAtIndex:(NSInteger)index { }

我正在尝试实现这个但它没有给出正确的结果请任何人告诉这个正确的实现

谢谢

最佳答案

像这样设置iCarousel的DataSource和Delegate

enter image description here

然后在 .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/

相关文章:

iphone - 在 SQLite 中获取表中填充行的总数

ios - 在iOS/macOS上处理过时的现代方法

ios - 注册推送通知没有得到任何响应

ios - UIImageView 之间的碰撞检测

ios - 如何根据屏幕尺寸更改 icarousel 半径?

ios - 向 iCarousel 项目添加自定义手势

iphone - iCarousel 从 NSMutableArray 加载 UIViews

ios - 我可以找出应用程序图标在主屏幕上的位置吗?