gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:11 26 4
gpt4 key购买 nike

我正在制作一个包含旋转木马的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com