0
스크롤 뷰를 사용하여 이미지 뷰에서 이미지를로드 한 다음 이미지를 저장하고 싶습니다. 컬렉션에 저장하고 있습니다. 내가 이미지를 저장할 때 그래서 항상 PAGENUMBER = 1 만 내가 무엇을 페이지 때를 추가 할 필요에만 당신은 스크롤 뷰에 대한 페이징을 활성화해야ScrollView에서로드 된 데이터베이스에 이미지를 저장하는 방법
-(void) loadNews{
NSURL*myurl=url;
myurl = [myurl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
myurl = [myurl stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSURL*urlloaded= [[NSURL alloc]initWithString:myurl];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:urlloaded];
//Initialize the delegate.
RowTwoParser *parser = [[RowTwoParser alloc] initXMLParser];
//Set delegate
[xmlParser setDelegate:parser];
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
int k=0;
for (int i=0; i < [appDelegate.articles count]; i++) {
currentIndex=i;
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView*subView=[[UIView alloc ]initWithFrame:frame];
[self.scrollView addSubview:subView];
RowTwo*aRowTwo=[appDelegate.articles objectAtIndex:i];
CGRect mywebframe=CGRectMake(20, 60, 728, 800);
UIImageView*imageView=[[UIImageView alloc] initWithFrame:mywebframe];
NSString*thumb2=aRowTwo.image;
thumb2 = [thumb2 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
thumb2 = [thumb2 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSURL *url = [NSURL URLWithString:thumb2];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
UIImage *image2 = [[UIImage alloc] initWithData:data];
imageView.image =image2 ;
[subView addSubview:imageView];
}
//NSInteger numberofPages=10-j;
NSInteger numberofPages=[appDelegate.articles count];
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * numberofPages, self.scrollView.frame.size.height);
CGRect frame;
//frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage;
frame.origin.x = self.scrollView.frame.size.width * myindex;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
[self.scrollView scrollRectToVisible:frame animated:YES];
[pageControl setNumberOfPages:numberofPages];
[pageControl setActivePageColor:[UIColor clearColor]];
[pageControl setInactivePageColor:[UIColor clearColor]];
}
-(IBAction)addToCollectionButtonAction{
GeoNewsAppDelegate *appDelegate = (GeoNewsAppDelegate *)[[UIApplication sharedApplication] delegate];
// Create a Coffee Object.
Coffee *coffeeObj = [[Coffee alloc] initWithPrimaryKey:0];
int pageNumber = [pageControl currentPage];
NSLog(collectionImage);
RowTwo*aRowTwo=[appDelegate.articles objectAtIndex:pageNumber];
NSString*thumb2=aRowTwo.image;
coffeeObj.thumb = thumb2;
coffeeObj.path = thumb2;
[appDelegate addCoffee:coffeeObj];
}
나는 thsi와 비슷하지만 pageControl.currentPage의 값 1을 다시 보여줍니다. –
UIScrollView Paging 잘 작동하지 않습니다 .- 귀하의 질문은 바로이 것입니까? 코드가 이해할 수없는 경우, 짧은 메모와 각 mthd를 작성하십시오. – vishy
페이징 잘 작동하지만 내 질문은 예를 들어 2 페이지에 있습니다 그리고 당신은 컬렉션에 그 이미지를 추가하는 버튼을 클릭하십시오. 그 페이지의 이미지는 저장하지 않지만 page1을 저장하면 –