Skip to content

Commit

Permalink
- include sample code to use PageControlStyleThumb
Browse files Browse the repository at this point in the history
  • Loading branch information
honcheng committed Jan 30, 2012
1 parent 9e53ac7 commit 8da26bd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
16 changes: 16 additions & 0 deletions StyledPageControlDemo/PageControlDemo.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
F84A251214D6E6270057C3A5 /* pagecontrol-thumb-selected.png in Resources */ = {isa = PBXBuildFile; fileRef = F84A250E14D6E6270057C3A5 /* pagecontrol-thumb-selected.png */; };
F84A251314D6E6270057C3A5 /* pagecontrol-thumb-selected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F84A250F14D6E6270057C3A5 /* pagecontrol-thumb-selected@2x.png */; };
F84A251414D6E6270057C3A5 /* pagecontrol-thumb-normal.png in Resources */ = {isa = PBXBuildFile; fileRef = F84A251014D6E6270057C3A5 /* pagecontrol-thumb-normal.png */; };
F84A251514D6E6270057C3A5 /* pagecontrol-thumb-normal@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F84A251114D6E6270057C3A5 /* pagecontrol-thumb-normal@2x.png */; };
F8B2E731137ED3C500338230 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B2E730137ED3C500338230 /* UIKit.framework */; };
F8B2E733137ED3C500338230 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B2E732137ED3C500338230 /* Foundation.framework */; };
F8B2E735137ED3C500338230 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B2E734137ED3C500338230 /* CoreGraphics.framework */; };
Expand All @@ -23,6 +27,10 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
F84A250E14D6E6270057C3A5 /* pagecontrol-thumb-selected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pagecontrol-thumb-selected.png"; path = "Resources/pagecontrol-thumb-selected.png"; sourceTree = "<group>"; };
F84A250F14D6E6270057C3A5 /* pagecontrol-thumb-selected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pagecontrol-thumb-selected@2x.png"; path = "Resources/pagecontrol-thumb-selected@2x.png"; sourceTree = "<group>"; };
F84A251014D6E6270057C3A5 /* pagecontrol-thumb-normal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pagecontrol-thumb-normal.png"; path = "Resources/pagecontrol-thumb-normal.png"; sourceTree = "<group>"; };
F84A251114D6E6270057C3A5 /* pagecontrol-thumb-normal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pagecontrol-thumb-normal@2x.png"; path = "Resources/pagecontrol-thumb-normal@2x.png"; sourceTree = "<group>"; };
F8B2E72C137ED3C500338230 /* PageControlDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PageControlDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
F8B2E730137ED3C500338230 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
F8B2E732137ED3C500338230 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -108,6 +116,10 @@
F8B2E737137ED3C500338230 /* Supporting Files */ = {
isa = PBXGroup;
children = (
F84A250E14D6E6270057C3A5 /* pagecontrol-thumb-selected.png */,
F84A250F14D6E6270057C3A5 /* pagecontrol-thumb-selected@2x.png */,
F84A251014D6E6270057C3A5 /* pagecontrol-thumb-normal.png */,
F84A251114D6E6270057C3A5 /* pagecontrol-thumb-normal@2x.png */,
F8B2E738137ED3C500338230 /* PageControlDemo-Info.plist */,
F8B2E739137ED3C500338230 /* InfoPlist.strings */,
F8B2E73C137ED3C500338230 /* PageControlDemo-Prefix.pch */,
Expand Down Expand Up @@ -198,6 +210,10 @@
F8B2E73B137ED3C500338230 /* InfoPlist.strings in Resources */,
F8B2E748137ED3C500338230 /* MainWindow_iPhone.xib in Resources */,
F8B2E74F137ED3C500338230 /* MainWindow_iPad.xib in Resources */,
F84A251214D6E6270057C3A5 /* pagecontrol-thumb-selected.png in Resources */,
F84A251314D6E6270057C3A5 /* pagecontrol-thumb-selected@2x.png in Resources */,
F84A251414D6E6270057C3A5 /* pagecontrol-thumb-normal.png in Resources */,
F84A251514D6E6270057C3A5 /* pagecontrol-thumb-normal@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Expand Up @@ -85,7 +85,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 5;
return 6;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand All @@ -110,6 +110,10 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
{
return 1;
}
else if (section==5)
{
return 1;
}
else return 0;
}

Expand All @@ -135,12 +139,16 @@ - (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteg
{
return @"PageControlStyleWithPageNumber";
}
else if (section==5)
{
return @"PageControlStyleThumb";
}
else return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
return 34;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down Expand Up @@ -195,7 +203,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell.pageControl setPageControlStyle:PageControlStyleWithPageNumber];
[cell.pageControl setNumberOfPages:14];
}

else if (indexPath.section==5)
{
[cell.pageControl setPageControlStyle:PageControlStyleThumb];
[cell.pageControl setThumbImage:[UIImage imageNamed:@"pagecontrol-thumb-normal.png"]];
[cell.pageControl setSelectedThumbImage:[UIImage imageNamed:@"pagecontrol-thumb-selected.png"]];
[cell.pageControl setNumberOfPages:10];
}

return cell;
}
Expand Down
Expand Up @@ -23,15 +23,15 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
[self.contentView addSubview:self.pageControl];
[self.pageControl release];

[self setSelectionStyle:UITableViewCellEditingStyleNone];
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
}
return self;
}

- (void)layoutSubviews
{
[super layoutSubviews];
[self.pageControl setFrame:CGRectMake(20,10,self.frame.size.width-40,20)];
[self.pageControl setFrame:CGRectMake(20,(self.frame.size.height-20)/2,self.frame.size.width-40,20)];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8da26bd

Please sign in to comment.