How to next image in scroll view by next button in iphone - iphone

I have image in scroll view it is loading images from the array i also want this that when i press nextbutton next image should appear I have done following code for loading images in scrollview i want to go prevoius and next image by button click when i click next button it doesw not show next image
-(void) loadNews{
NSURL*myurl=url;
myurl = [myurl stringByReplacingOccurrencesOfString:#"\n" withString:#""];
myurl = [myurl stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSURL*urlloaded= [[NSURL alloc]initWithString:myurl];
//NSURL*url= [[NSURL alloc]initWithString:#"http://localhost:8888/RowOne.xml"];
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++) {
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];
k++;
}
//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]];
}
Next Button Code
-(IBAction)nextButton{
for (int nextIndex=[pageControl currentPage]; nextIndex < [appDelegate.articles count]; nextIndex++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * nextIndex;
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:nextIndex];
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];
// k+\
}
//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]];
}

If they are in scroll view, you use
CGPoint offset = CGPointMake(xPositionToScroll, yPositionToScroll);
[self.scrollView setContentOffset:topOffset animated:YES];
To some specific point.

Related

ImageGallery image in black for ios 7

In my efforts to upgrade my application to support IOS7 I found out that ImageGallery don't load the images. in others iOS is ok.
In imageGalleryView:
- (void)initWithPhotos:(NSMutableArray *)photoURLStrings andCaptions:(NSArray *)myCaptions moveToPage:(int)page {
captions = [myCaptions copy];
photoUrls = [photoURLStrings copy];
NSLog(#"array---> %#", photoUrls);
photoLoaded = [[NSMutableArray alloc] init];
for (int i=0; i<[photoURLStrings count]; i++) {
[photoLoaded addObject:[NSNumber numberWithBool:FALSE]];
}
[pageControl setNumberOfPages:[photoUrls count]];
//scrollView= [[UIScrollView alloc] init];
scrollView.backgroundColor = [UIColor blackColor];
scrollView.pagingEnabled = TRUE;
scrollView.autoresizesSubviews = TRUE;
scrollView.contentSize = CGSizeMake(320 * [photoUrls count], scrollView.frame.size.height);
scrollView.contentOffset = CGPointMake(self.scrollView.frame.size.width*page, 0);
if (([captions objectAtIndex:page] == nil) || ([[captions objectAtIndex:page] isEqualToString:#""])) {
[textView setHidden:TRUE];
} else {
[textView setHidden:FALSE];
[textView setText:[captions objectAtIndex:page]];
}
[self showImages:page];}
- (void)showImages:(int)page {
AsyncImageViewController *asyncImageView;
if ((page>=0)&&(page<[photoUrls count])) {
if (![[photoLoaded objectAtIndex:page] boolValue]) {
[photoLoaded replaceObjectAtIndex:page withObject:[NSNumber numberWithBool:TRUE]];
asyncImageView = [[AsyncImageViewController alloc] init];
//NSLog(#"%#",[NSString stringWithFormat:#"%#",[photoUrls objectAtIndex:page]]);
[asyncImageView loadImageFromURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#",[photoUrls objectAtIndex:page]]] pos:1];
//NSLog(#"page:%i",page);
asyncImageView.frame = CGRectMake(320*page,0,320,scrollView.frame.size.height);
//[scrollView setBackgroundColor:[UIColor colorWithPatternImage:asyncImageView.image]];
[scrollView addSubview:asyncImageView];
[asyncImageView release];
}
}
page = page - 1;
if ((page>=0)&&(page<[photoUrls count])) {
if (![[photoLoaded objectAtIndex:page] boolValue]) {
[photoLoaded replaceObjectAtIndex:page withObject:[NSNumber numberWithBool:TRUE]];
asyncImageView = [[AsyncImageViewController alloc] init];
[asyncImageView loadImageFromURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#",[photoUrls objectAtIndex:page]]] pos:1];
asyncImageView.frame = CGRectMake(320*page,0,320,scrollView.frame.size.height);
[scrollView addSubview:asyncImageView];
[asyncImageView release];
}
}
page = page + 2;
if ((page>=0)&&(page<[photoUrls count])) {
if (![[photoLoaded objectAtIndex:page] boolValue]) {
[photoLoaded replaceObjectAtIndex:page withObject:[NSNumber numberWithBool:TRUE]];
asyncImageView = [[AsyncImageViewController alloc] init];
[asyncImageView loadImageFromURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#",[photoUrls objectAtIndex:page]]] pos:1];
asyncImageView.frame = CGRectMake(320*page,0,320,scrollView.frame.size.height);
[scrollView addSubview:asyncImageView];
//[scrollView setBackgroundColor:[UIColor colorWithPatternImage:asyncImageView.image]];
[asyncImageView release];}}}
In the asyncimageview:
- (void)loadImageFromURL:(NSURL*)url pos:(int) posicio {
if (connection!=nil) { [connection release]; }
if (data!=nil) { [data release]; }
NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
if (posicio == 0) {
loading.center = CGPointMake(75/2,75/2);
}else {
loading.center = CGPointMake(160,210);
}
[loading startAnimating];
[self addSubview:loading];
[loading release];}//the URL connection calls this repeatedly as data arrives- (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData {
if (data==nil) { data = [[NSMutableData alloc] initWithCapacity:2048]; }
[data appendData:incrementalData];}//the URL connection calls this once all the data has downloaded- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection {
//so self data now has the complete image
[connection release];
connection=nil;
if ([[self subviews] count]>0) {
//then this must be another image, the old one is still in subviews
[[[self subviews] objectAtIndex:0] removeFromSuperview]; //so remove it (releases it also)
}//make an image view for the image
imageView = [[[UIImageView alloc] initWithImage:[UIImage imageWithData:data]] autorelease];
//make sizing choices based on your needs, experiment with these. maybe not all the calls below are needed.
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight );
//[self setBackgroundColor:[UIColor colorWithPatternImage:imageView]];
[self addSubview:imageView];
imageView.frame = self.bounds;
[imageView setNeedsLayout];
[self setNeedsLayout];
[loading stopAnimating];
[data release]; //don't need this any more, its in the UIImageView now
data=nil;}
//just in case you want to get the image directly, here it is in subviews- (UIImage*) image {
UIImageView* iv = [[self subviews] objectAtIndex:0];
return [iv image];}
I checked all and saw that it is UIView instead of UIImageView. probably Apple changed something. But xCode don't throw any errors.
Any idea how to fix it?

UIScrollView has White Space above SubViews

I am running across a weird issue, which I can't seem to figure out.
Upon adding multiple SubViews to a ScrollView, the ScrollViews keeps on adding a White Space ontop of the regular image
A bit better with more colors:
This is how it should look like:
The Image is perfectly scrollable.
This is the code I'm using to create the scrollview:
-(void)addImagesToScrollView
{
if (self.product != nil)
{
int imageCount = 0;
if (self.product.labelImage != nil)
{
UIImageView *labelImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
labelImage.image = [UIImage imageWithData:self.product.labelImage];
labelImage.contentMode = UIViewContentModeScaleAspectFit;
labelImage.tag = 100;
[self.scrollView addSubview:labelImage];
imageCount += 1;
}
if (self.product.bottleImage != nil)
{
UIImageView *bottleImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.scrollView.frame.size.width, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
bottleImage.image = [UIImage imageWithData:self.product.bottleImage];
bottleImage.contentMode = UIViewContentModeScaleAspectFit;
bottleImage.tag = 101;
imageCount += 1;
[self.scrollView addSubview:bottleImage];
}
if (self.product.pourImage != nil)
{
UIImageView *pourImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.scrollView.frame.size.width * 2, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
pourImage.image = [UIImage imageWithData:self.product.pourImage];
pourImage.contentMode = UIViewContentModeScaleAspectFit;
pourImage.tag = 102;
imageCount += 1;
[self.scrollView addSubview:pourImage];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * imageCount, self.scrollView.frame.size.height);
[self.scrollView setContentOffset:CGPointZero animated:NO];
}
}
Edit:
With a BackgroundColor:
use:
bottleImage.layer.color = [UIcolor blueColor].CGColor;
bottleImage.layer.borderWidth = 2.0f;
It will let you see the frame of your UIImageView maybe you are calculating incorrectly the frame
Use below code and you will get desired output. In the following code you app will use album photos and automatically sets size of the scrolling as per the number of images in album. And please modify according to your image repository.
-(void)getAllPictures
{
imageArray=[[NSArray alloc] init];
mutableArray =[[NSMutableArray alloc]init];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset) {
[mutableArray addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
if ([mutableArray count]==count)
{
imageArray=[[NSArray alloc] initWithArray:mutableArray];
[self allPhotosCollected:imageArray];
}
}
failureBlock:^(NSError *error){ NSLog(#"operation was not successfull!"); } ];
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
count=[group numberOfAssets];
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(#"There is an error");}];
}
-(void)allPhotosCollected:(NSArray*)imgArray
{
CGSize imageSize;
imageSize.width= imageView.bounds.size.width;
imageSize.height = imageView.bounds.size.height;
self.scrollView=[[UIScrollView alloc]init];
self.scrollView.frame = imageView.frame;
self.scrollView.contentSize = CGSizeMake(imageSize.width * imgArray.count, imageSize.height);
self.scrollView.pagingEnabled = YES;
self.scrollView.bounces=YES;
self.scrollView.scrollEnabled = YES;
self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
[self.scrollView flashScrollIndicators];
[self.view addSubview:self.scrollView];
CGFloat xPos = 0.0;
for (UIImage *image in imgArray) {
imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(xPos, 0.0, imageSize.width, imageSize.height);
[self.scrollView addSubview:imageView];
xPos += imageSize.width;
// assuming ARC, otherwise release imageView
}
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20,320 , 420)];
[self getAllPictures];
}

How to show image loaded from a url on a button?

Here is an example :
Show multi image on multi button and show on scrollview
(void)viewDidLoad
{
[super viewDidLoad];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
InitData *inData=[[InitData alloc]init];
scrollview.delegate=self;
scrollview.scrollEnabled = YES;
int scrollWidth = 120;
scrollview.contentSize = CGSizeMake(scrollWidth,100);
int xOffset = 0;
//imageView.image = [UIImage imageNamed:[imagesName objectAtIndex:0]];
//Test
NSURL *url=[NSURL URLWithString:#"....."];
NSData *jsonData=[NSData dataWithContentsOfURL:url];
if (jsonData !=nil)
{
NSError *error=nil;
id result=[NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
if (error ==nil)
{
NSLog(#"%#",result);
// NSMutableArray *ArImg = nil;
NSArray* rus=[result objectForKey:#"RespOBJ"];
for (int index = 0; index < rus.count ; index++)
{
NSMutableDictionary* final=[rus objectAtIndex:index];
[inData setId:(int)[final objectForKey:#"Id"]];
[inData setTum:[final objectForKey:#"TumbImage"]];
[inData setImage:[final objectForKey:#"Image"]];
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:[inData getImage]] forState:(UIControlStateNormal)];
//[btn setImage:[UIImage imageWithData:jsonData] forState:(UIControlStateNormal)];
[btn setTag:index];
btn.bounds = CGRectMake(10, 10, 50, 50);
btn.frame = CGRectMake(5+xOffset, 0, 160, 70);
scrollview.contentSize = CGSizeMake(scrollWidth+xOffset,70);
NSLog(#"%#",[inData getId]);
NSLog(#"%#",[inData getImage]);
NSLog(#"%#",[inData getTum]);
[btn addTarget:self
action: #selector(btnclick:)
forControlEvents: UIControlEventTouchDown];
[scrollview addSubview:btn];
xOffset += 170;
}
The problem with your code is that you are not loading anything. I assume you want to download the image from the Internet and then display it on the scrollview. To do so, you have to use a NSURLRequest and a NSURLConnection.
Have a look at Apple's documentation https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html and https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
You might also like this question on how to load data asynchronously Object-c/iOS :How to use ASynchronous to get a data from URL?

How to save image in data base loaded in ScrollView

I am using scroll view to load images in image view from array and then what ever image i want to save i am save to collection. So when i save image it always takes the pageNumber = 1 only I want that what ever page when add it only adds page which is at number one not others
-(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];
}
You need to enable paging for scroll view
self.scrollView.pagingEnabled = YES

UIScrollView to jump particular page

I have a scroll view containing webview and webview is displaying content from xml. for e.g i have 10 pages . so if a want to go particular page how should i go to that page
int j=myindex;
int k=0;
for (int i=0; i < [appDelegate.books count]; i++) {
if (j>i) {
// //j++;
continue;
}
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * k;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView*subView=[[UIView alloc ]initWithFrame:frame];
//subView.backgroundColor=[appDelegate.books objectAtIndex:i];
[self.scrollView addSubview:subView];
CGRect myframe=CGRectMake(8, 16, 371, 242);
UIImageView*imageView=[[UIImageView alloc] initWithFrame:myframe];
Book*aBook=[appDelegate.books objectAtIndex:i];
NSString*myimage=aBook.mainimgurl;
myimage = [myimage stringByReplacingOccurrencesOfString:#"\n" withString:#""];
myimage = [myimage stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:myimage]]];
j++;
imageView.image=image;
CGRect mywebframe=CGRectMake(0, 30, 768, 876);
UIWebView*webView=[[UIWebView alloc] initWithFrame:mywebframe];
/*NSString*title=aBook.title;
NSString*mytitle=#"Rask og grønn";
title = [title stringByReplacingOccurrencesOfString:#"\n" withString:#""];
title = [title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString*mytitle1=#"Fortidsklimaet på Svalbard";
if ([title isEqualToString:mytitle ] || [title isEqualToString:mytitle1]) {
htmlString=aBook.magazinenumberdescription;
}*/
if (aBook.fulltext==nil) {
htmlString=aBook.magazinenumberdescription;
}
else {
htmlString=aBook.fulltext;
}
//NSString*htmlString=aBook.description;
[webView loadHTMLString:htmlString baseURL:nil];
[subView addSubview:webView];
CGRect myframe1=CGRectMake(387, 16, 363, 292);
UITextView*textView=[[UITextView alloc] initWithFrame:myframe1];
textView.font=[UIFont fontWithName:#"Times New Roman" size:16];
NSString*description=aBook.description;
description = [description stringByReplacingOccurrencesOfString:#"\n" withString:#""];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"å" withString:#"å"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"ø" withString:#"ø"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"æ" withString:#"æ"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"Æ" withString:#"Æ"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"Ø" withString:#"Ø"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
description = [description stringByReplacingOccurrencesOfString:#"&Aring" withString:#"Å"];
description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
k++;
textView.text=description;
// [subView addSubview:textView];
// [subView addSubview:imageView];
}
//NSInteger numberofPages=10-j;
NSInteger numberofPages=[appDelegate.books count];
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * numberofPages, self.scrollView.frame.size.height);
[pageControl setNumberOfPages:numberofPages];
[pageControl setActivePageColor:[UIColor clearColor]];
[pageControl setInactivePageColor:[UIColor clearColor]];
try this :
- (void) viewDidLoad // Or any other method
{
[myScroll scrollRectToVisible:CGRectMake(320*pageNumber, 0, 320 , 240) animated:NO];
//320 is a width of my page,you have to replace it with your page's width
[self.view addSubview:myScroll];
}
hope this helps you..