IOS_9_scrollView paging, iosscrollview attributes
Finally:
BeyondViewController. h
//// BeyondViewController. h // 8_scrollVIew page views /// Created by beyond on 14-7-25. // Copyright (c) 2014 com. beyond. all rights reserved. // # import <UIKit/UIKit. h> @ interface BeyondViewController: UIViewController @ property (weak, nonatomic) IBOutlet UIScrollView * scrollView; @ end
BeyondViewController. m
//// BeyondViewController. m // 8_scrollVIew paging browsing/* the following code has performance problems. It is only used as a new feature introduction interface and cannot be used as an image browser ~ 1. performance problems may occur when eight imageviews are generated at a time. Solution: Use 3 imageviews (or 2 imageviews) 2. In addition, loop playback has not yet been implemented * // Created by beyond on 14-7-25. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "// total number of images # define kImgCount 8 @ interface BeyondViewController () <UIScrollViewDelegate >{// the paging Bar Code Indicator controller UIPageControl * _ pageControl ;} @ end @ implementation BeyondViewController-(void) viewDidLoad {[super viewDidLo Ad]; // call the custom method [self scrollViewWithPage];} // scrollView with paging function-(void) scrollViewWithPage {// 1, and set the visible size of the scrollView, content size, and other attributes _ scrollView. frame = self. view. bounds; _ scrollView. showsHorizontalScrollIndicator = NO; _ scrollView. showsVerticalScrollIndicator = NO; _ scrollView. bouncesZoom = NO; _ scrollView. bounces = NO; // set the code to listen to the rolling Event _ scrollView. delegate = self; // 2. Create eight uiimageviews and add them to scrollView. // each image Width, high CGFloat imgW = self. view. bounds. size. width; CGFloat imgH = self. view. bounds. size. height; for (int I = 0; I <kImgCount; I ++) {// UIImageView // image name: 01.jpg ~ 07. jpg NSString * imgName = [NSString stringWithFormat: @ "02.16d.png", I + 1]; UIImageView * imgView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imgName]; // if the image in the imageView is not deformed, // set the following two attributes of the UIImageView object, the image is not deformed and filled with the image box. ImgView. clipsToBounds = YES; imgView. contentMode = UIViewContentModeScaleAspectFill; // y is 0, and x is connected to an imgView. frame = CGRectMake (I * imgW, 0, imgW, imgH); // Add all the images to scrollView [_ scrollView addSubview: imgView];} // 3, the most important thing is the scrolling area // _ scrollView. contentSize = CGSizeMake (kImgCount * imgW, imgH); // 0 indicates that the height direction is not scrollView. contentSize = CGSizeMake (kImgCount * imgW, 0); // page by the width of scrollView _ scrollView. pagingEnabled = YES; // 4, pageControl pagination indicator BAR _ pageControl = [[UIPageControl alloc] init]; // pageControl indicates the center of the pageControl page indicator bar in the middle of the bottom _ pageControl. numberOfPages = kImgCount; // The Most Important _ pageControl. center = CGPointMake (imgW * 0.5, imgH-20); _ pageControl. bounds = CGRectMake (0, 0,150, 15); _ pageControl. pageIndicatorTintColor = [UIColor grayColor]; _ pageControl. currentPageIndicatorTintColor = [UIColor redColor]; _ pageControl. enabled = NO; // cancel the default click behavior [self. view addSubview: _ pageControl];}/* In this method, you can optimize the performance. Because you are always listening for scrolling, You can splice three uiimageviews at any time, it can even be reduced to only two uiimageviews for dynamic stitching */-(void) scrollViewDidScroll :( UIScrollView *) scrollView {// contentOffset of scrollView is the most important attribute, point, x, y records the scroll distance, and CGPoint offset = scrollView in the upper left corner of the scrollView visual interface. contentOffset; int curPageNo = offset. x/_ scrollView. bounds. size. width; _ pageControl. currentPage = curPageNo;} @ end
How to Implement pagination in gridview?
Gridview has its own paging function.
You can use this event.
Protected void GridView1_PageIndexChanging (object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e. NewPageIndex;
Bind (Bid); // Bind data to the gridview
}
How to display by page?
Currently, the best JSP paging technology
In the process of using the database, it is inevitable to use the paging function, but the JDBC specification does not solve this well. Many of my friends have their own solutions for this demand. For example, we use a collection class such as Vector to save the Retrieved Data first and then pagination. However, this method has poor availability, which is completely different from the JDBC interface and does not support different types of fields. A solution with good compatibility with JDBC is provided here.
JDBC and paging
Sun's JDBC specification is sometimes dumbfounded. In JDBC1.0, you can only perform the next () operation on a result set instead of rolling it backwards, this directly leads to the failure to obtain the size of the result set when only one SQL query is executed. Therefore, if you are using the JDBC1.0 driver, paging is almost impossible.
Fortunately, Sun's JDBC2 specification makes up for this deficiency and adds the frontend and backend scrolling operations of the result set. Although it still cannot directly support paging, however, you can write your own ResultSet that supports pagination on this basis.
Implementation methods related to specific databases
Some databases, such as Mysql and Oracle, have their own paging methods. For example, Mysql can use the limit clause, and Oracle can use ROWNUM to limit the size and start position of the result set. Take Mysql as an example. The typical code is as follows:
// Calculate the total number of records
String SQL = "SELECT Count (*) AS total" + this. QueryPart;
Rs = db.exe cuteQuery (SQL );
If (rs. next ())
Total = rs. getInt (1 );
// Set the current page number and total page number
TPages = (int) Math. ceil (double) this. Total/this. MaxLine );
CPages = (int) Math. floor (double) Offset/this. MaxLine + 1 );
// Retrieve the required records based on conditions
If (Total> 0 ){
SQL = Query + "LIMIT" + Offset + "," + MaxLine;
Rs = db.exe cuteQuery (SQL );
}
Return rs;
}
Without a doubt, this code will be beautiful when the database is Mysql, but as a general class (in fact, what I want to provide later is part of a general class library ), we need to adapt to different databases, and applications based on this class (database) may also use different databases. Therefore, we will not use this method.
Another tedious Implementation Method
I have seen some people's practices (in fact, this method was used at the beginning, including me), that is, no encapsulation is used, where paging is required, directly perform the ResultSet operation to roll to the corresponding location and then read the corresponding number of records. The typical code is as follows:
<%
SqlStmt = sqlCon. createStatement (java. SQL. ResultSet. TYPE_SCROLL_INSENSITIVE,
Java. SQL. ResultSet. CONCUR_READ_ONLY );
StrSQL = "select name, age from test ";
// Execute the SQL statement and obtain the result set
SqlRst = sqlStmt.exe cuteQuery (strSQL );
// Obtain the total number of records
SqlR ...... remaining full text>