HI全部 任何人都可以請參考我的iphone圖庫源代碼? 任何鏈接,示例代碼將非常有幫助。IPhone圖片庫源代碼
我想顯示一些70至100的圖像作爲縮略圖,並選擇任何圖像,它應該給出該圖像的完整視圖,我試圖完成,無論是在iphone的圖片庫, 我想,必須有任何示例代碼可用。 建議總是理解
問候
HI全部 任何人都可以請參考我的iphone圖庫源代碼? 任何鏈接,示例代碼將非常有幫助。IPhone圖片庫源代碼
我想顯示一些70至100的圖像作爲縮略圖,並選擇任何圖像,它應該給出該圖像的完整視圖,我試圖完成,無論是在iphone的圖片庫, 我想,必須有任何示例代碼可用。 建議總是理解
問候
在didload方法調用兩種方法來創建滾動視圖和縮略圖button.Keep兩個縮略圖圖像並以相同的順序牆紙圖像陣列。
-(void)createScrollView
{
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 440)];
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
scrollView.contentSize = CGSizeMake(320 * (([imagesArray count]- 1)/25 + 1), 440);
scrollView.backgroundColor=[UIColor blackColor];
[self.view addSubview:scrollView];
}
-(void)createButton{
for (int i = 0; i < [imagesArray count]; i++)
{
thumbNailButton = [UIButton buttonWithType:UIButtonTypeCustom];
thumbNailButton.frame = CGRectMake(6 + 62 * (i % 5) + 320 * (i/25), 5+65 * ((i/5) % 5), 56,56);
img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 56, 56)];
[img setImage:[UIImage imageNamed:[imagesArray objectAtIndex:i]]];
thumbNailButton.tag=i;
[thumbNailButton addTarget:self action:@selector(imageClicked:) forControlEvents:UIControlEventTouchUpInside];
[thumbNailButton addSubview:img];
[scrollView addSubview:thumbNailButton];
}
}
-(void)imageClicked:(id)sender{
UIButton* button = (UIButton*)sender;
AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
[appDelegate setimageClickedValue:button.tag];
LargeWallPaperviewController *largeWallPaperViewController=[[LargeWallPaperviewController alloc]initWithNibName:@"LargeWallPaperviewController" bundle:nil];
[self.navigationController pushViewController:largeWallPaperViewController animated:YES];
[largeWallPaperViewController release];
}
在didload方法largewallpaperviewcontroller類
[imagesArray addObjectsFromArray:[NSArray arrayWithObjects:@"wallf1.jpg",@"wallf2.jpg",@"wallf3.jpg",@"wallf4.jpg",@"wallf5.jpg",@"wallf6.jpg",@"wallf7.jpg",nil]];
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 440)];
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
scrollView.contentSize = CGSizeMake(320 * ([imagesArray count]), 440);
scrollView.backgroundColor = [UIColor blackColor];
[self.view addSubview:scrollView];
for (int i = 0; i < [imagesArray count]; i++)
{
wallPaperButton=[UIButton buttonWithType:UIButtonTypeCustom];
wallPaperButton.tag=i;
wallPaperButton.frame=CGRectMake((320*i),0, 320, 325);
UIImageView *img =[ [UIImageView alloc]initWithFrame:CGRectMake(0,0, 320, 325)];
img.image=[UIImage imageNamed:[imagesArray objectAtIndex:i]];
img.contentMode=UIViewContentModeScaleAspectFit;
[wallPaperButton addSubview:img];
[img release];
[wallPaperButton addTarget:self action:@selector(imageSelected:) forControlEvents:UIControlEventTouchUpInside]; [scrollView addSubview:wallPaperButton];
}
appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
int imageValue=[appDelegate getimageClickedValue];
[scrollView scrollRectToVisible:CGRectMake(320*imageValue, 0, 320 , 440) animated:NO];
我已經在largewallpaer使用的按鈕view.If你希望你刪除它,並直接將其添加到圖像view.This代碼爲我工作,將其更改爲您的要求。它易於理解。
一切順利。
@ warrior.can你幫我我需要在每個添加4行3images如果我有52張圖片,可以幫助我根據這個要求修正你的公式.thumbNailButton.frame = CGRectMake(6 + 62 *(i%5)+ 320 *(i/25),5 + 65 *((i/5)%5),56,56);我非常震驚。 – hacker 2013-03-01 15:40:32
關閉此代碼。這工作完美。自從我使用故事板以來,我修改了「appdelegate部分」。
這裏是我做的,而不是應用程序委託我只是用
-(void)imageClicked:(id)sender{
UIButton* button = (UIButton*)sender;
imageNumber = button.tag;
[self performSegueWithIdentifier:@"loadImage" sender:sender];
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"loadImage"])
{
[segue.destinationViewController setimageValue:imageNumber];
}
}
而且在我的目的地View Controller.m
文件命名爲'ImageViewController'
我實現的事情如下
-(void)setimageValue:(int)number;
{
self.imageValue = number;
}
而且在viewDidLoad
,
[self.scrollView scrollRectToVisible:CGRectMake(320*self.imageValue, 0, 320 , 440) animated:NO];
你可以添加更多的點來提及你n準確地 – Warrior 2010-10-25 05:44:25
編輯我的問題我的朋友。 – iscavengers 2010-10-25 05:52:04
您在本地有圖像還是想在運行時下載? – Warrior 2010-10-25 06:39:31