1
테이블 뷰 사용자 정의 셀에 다른 사진 수가 있습니다. 이제 그 사진을 표시하고 싶습니다. 다음 페이지 4 행마다 사진을 보내주세요. 할 수 있습니까?아이폰에 gridview 또는 imagegallery에 사진을 표시하는 방법
테이블 뷰 사용자 정의 셀에 다른 사진 수가 있습니다. 이제 그 사진을 표시하고 싶습니다. 다음 페이지 4 행마다 사진을 보내주세요. 할 수 있습니까?아이폰에 gridview 또는 imagegallery에 사진을 표시하는 방법
당신은 이것에 대한 UIScrollView
을 사용할 수 있습니다 ...
그리드의 각 항목은 당신이 당신의 UIScrollView
에 파단으로 추가 할 UIImageView
이다.
다음 코드는보기 컨트롤러 안의 viewDidLoad
에 삽입 할 수 있으며 인터페이스 작성기에 UISCrollView를 설정했다고 가정합니다. 그렇지 않으면 viewDidLoad
안에 스크롤보기를 할당해야합니다.
코드는 4 개의 열이있는 UIScrollView에 가변 개수의 이미지 항목을 추가합니다.
UIImageView *imageView = nil;
//The x and y view location coordinates for your menu items
int x = 0, y = 0;
//The number of images you want
int numOfItemsToAdd = 10;
//The height and width of your images are the screen width devided by the number of columns
int imageHeight = 320/4, imageWidth = 320/4;
int numberOfColumns = 4;
//The content seize needs to refelect the number of items that will be added
[scrollView setContentSize:CGSizeMake(320, imageHeight*numOfItemsToAdd];
for(int i=0; i<numOfItemsToAdd; i++){
if(i%numberOfColumns == 0){//% the number of columns you want
x = 0;
if(i!=0)
y += imageHeight;
}else{
x = imageHeight;
}
imageView = [[UIImageView alloc] initWithFrame: CGRectMake(x, y, imageWidth, imageHeight)];
//set the center of the image in the scrollviews coordinate system
imageView.center = CGPointMake(x, y);
imageView.image = [UIImage imageNamed:@"my_photo.png"];
//Finaly add the image to the scorll view
[scrollView addSubview:imageView];
thnx.i도 동일한 해결책을 구현합니다. – nehal
항목 선택은 어떻게 처리합니까? – ADude