ProductListViewContrller complete

This commit is contained in:
2014-08-13 11:44:54 +08:00
parent ca89d76411
commit aefb6b1d81
10 changed files with 162 additions and 30 deletions
@@ -29,12 +29,16 @@ static const NSUInteger kTagOfRightSideButton = 999;
_topScrollView.showsVerticalScrollIndicator = NO;
_topScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
//底部的线
// UIView* lineView = [[UIView alloc] initWithFrame:CGRectMake(0, kHeightOfTopScrollView, 320, 3)];
// lineView.alpha = 0.3;
// [lineView setBackgroundColor:[UIColor blackColor]];
// [_topScrollView addSubview:lineView]
[_topScrollView addSubview:[ManagerUtil lineWithColor:[UIColor grayColor] withAlpha:0.3 withFrame:CGRectMake(0, kHeightOfTopScrollView, 320, 1)]];
[self addSubview:_topScrollView];
_userSelectedChannelID = 100;
//创建主滚动视图
_rootScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kHeightOfTopScrollView, self.bounds.size.width, self.bounds.size.height - kHeightOfTopScrollView)];
_rootScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kHeightOfTopScrollView+1, self.bounds.size.width, self.bounds.size.height - kHeightOfTopScrollView)];
_rootScrollView.delegate = self;
_rootScrollView.pagingEnabled = YES;
_rootScrollView.userInteractionEnabled = YES;
+1 -1
View File
@@ -42,7 +42,7 @@
}
-(void)setLowestPriceWtihCount:(NSInteger)price
{
NSString* htmlStr = [NSString stringWithFormat:@"<span style=\" color:break; \">%ld</span>元起",price];
NSString* htmlStr = [NSString stringWithFormat:@"<span style=\" color:black; \">%ld</span>元起",price];
NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentRight],DTDefaultTextAlignment,[UIColor grayColor],DTDefaultTextColor, nil];
NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil];
+19 -13
View File
@@ -1,73 +1,79 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="QCf-WQ-E2P" customClass="FundListCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="108"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="109" id="QCf-WQ-E2P" customClass="FundListCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="109"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="QCf-WQ-E2P" id="tWO-H0-dwT">
<rect key="frame" x="0.0" y="0.0" width="320" height="107"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="108"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="我有五个字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jTX-Fg-izQ">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="我有五个字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="jTX-Fg-izQ">
<rect key="frame" x="10" y="14" width="140" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="小名字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iSf-Cf-gGc">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="小名字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iSf-Cf-gGc">
<rect key="frame" x="10" y="43" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Ly-0U-oSK">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4Ly-0U-oSK">
<rect key="frame" x="10" y="65" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.94664779970000001" green="0.21506300749999999" blue="0.1431705727" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="已经跑了30000米" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O3F-FR-wcE">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="已经跑了30000米" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="O3F-FR-wcE">
<rect key="frame" x="143" y="13" width="120" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="万分收益" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vsv-fO-QlW">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="万分收益" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="vsv-fO-QlW">
<rect key="frame" x="143" y="43" width="90" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="icb-Rm-6zW">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="icb-Rm-6zW">
<rect key="frame" x="143" y="65" width="90" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="fund_cell_label_bg_blue.png" translatesAutoresizingMaskIntoConstraints="NO" id="0hb-Ff-rGB">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="fund_cell_label_bg_blue.png" id="0hb-Ff-rGB">
<rect key="frame" x="283" y="14" width="30" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="D4z-2i-gXI" customClass="DTAttributedLabel">
<view contentMode="scaleToFill" id="D4z-2i-gXI" customClass="DTAttributedLabel">
<rect key="frame" x="238" y="47" width="67" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YEu-dt-BBV" customClass="DTAttributedLabel">
<view contentMode="scaleToFill" id="YEu-dt-BBV" customClass="DTAttributedLabel">
<rect key="frame" x="238" y="69" width="67" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<view alpha="0.29999999999999999" contentMode="scaleToFill" id="rlA-Zw-HRE">
<rect key="frame" x="0.0" y="106" width="320" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</subviews>
</tableViewCellContentView>
<connections>
@@ -28,12 +28,22 @@
[super viewDidLoad];
// Do any additional setup after loading the view.
}
#pragma mark MJRefreshDelegate
-(void)headerRereshing
{
_count = 15;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 刷新表格
[self.tableView reloadData];
[self headerEndRefreshing];
});
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
return _count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
@@ -11,9 +11,12 @@
@interface ListViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
{
__weak UITableView* _tableView;
NSInteger _count;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (assign, nonatomic)NSInteger count;
- (void)headerRereshing;
- (void)footerRereshing;
- (void)headerBeginRefreshing;
- (void)headerEndRefreshing;
@end
@@ -32,7 +32,7 @@
self.tableView.dataSource = self;
[self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
[self.tableView addFooterWithTarget:self action:@selector(footerRereshing)];
}
#pragma mark MJRefreshDelegate
- (void)headerRereshing
@@ -50,7 +50,6 @@
- (void)footerRereshing
{
// 2.2秒后刷新表格UI
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 刷新表格
@@ -60,6 +59,14 @@
[self.tableView footerEndRefreshing];
});
}
- (void)headerBeginRefreshing
{
[self.tableView headerBeginRefreshing];
}
-(void)headerEndRefreshing
{
[self.tableView headerEndRefreshing];
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
@@ -10,7 +10,8 @@
#import "AdjustableUILable.h"
#import "LoanListCell.h"
@interface LoanListViewController ()
{
}
@end
@implementation LoanListViewController
@@ -28,14 +29,24 @@
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self headerBeginRefreshing];
}
#pragma mark MJRefreshDelegate
-(void)headerRereshing
{
_count = 10;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 刷新表格
[self.tableView reloadData];
[self headerEndRefreshing];
});
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
return _count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
@@ -7,7 +7,7 @@
//
#import "OtherListViewController.h"
#import "FundListCell.h"
@interface OtherListViewController ()
@end
@@ -22,13 +22,50 @@
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
#pragma mark MJRefreshDelegate
-(void)headerRereshing
{
_count = 6;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 刷新表格
[self.tableView reloadData];
[self headerEndRefreshing];
});
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat height = 108.0;
return height;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *loanListCell = @"LoanListCell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:loanListCell];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:loanListCell];
NSArray *LoanListCellObjects = [[NSBundle mainBundle] loadNibNamed:@"FundListCell" owner:self options:nil];
cell = [LoanListCellObjects objectAtIndex:0];
}
[((FundListCell*)cell).totalLabel setText:@"已经有6783234人"];
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
@@ -11,6 +11,14 @@
#import "FundListViewController.h"
#import "OtherListViewController.h"
@interface ProductListViewController ()
{
LoanListViewController* _loanListViewController;
FundListViewController* _fundListViewController;
OtherListViewController* _otherListViewController;
NSInteger _nowSelectTab; //当前选择的界面。
}
@end
@@ -21,6 +29,13 @@
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
_loanListViewController = [[LoanListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
_loanListViewController.title = @"列表1";
_fundListViewController = [[FundListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
_fundListViewController.title = @"列表2";
_otherListViewController = [[OtherListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
_otherListViewController.title = @"列表3";
_nowSelectTab = 0;
}
return self;
}
@@ -30,6 +45,8 @@
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[ManagerUtil SetSubViewExternNone:self];
//右边按钮。
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightBarBtnClick:)]];
self.slideSwitchView.tabItemNormalColor = [QCSlideSwitchView colorFromHexRGB:@"868686"];
self.slideSwitchView.tabItemSelectedColor = [QCSlideSwitchView colorFromHexRGB:@"bb0b15"];
@@ -37,8 +54,27 @@
stretchableImageWithLeftCapWidth:59.0f topCapHeight:0.0f];
[self.navigationItem setTitle:@"第二页"];
[self.slideSwitchView buildUI];
}
#pragma mark method
-(void)rightBarBtnClick:(id)sender
{
switch (_nowSelectTab) {
case 0:
[_loanListViewController headerBeginRefreshing];
break;
case 1:
[_fundListViewController headerBeginRefreshing];
break;
case 2:
[_otherListViewController headerBeginRefreshing];
break;
default:
break;
}
}
#pragma mark - 滑动tab视图代理方法
@@ -55,21 +91,18 @@
switch (number) {
case 0:
{
viewController = [[LoanListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
viewController.title = @"列表1";
viewController = _loanListViewController;
}
break;
case 1:
{
viewController = [[FundListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
viewController.title = @"列表2";
viewController = _fundListViewController;
}
break;
case 2:
{
viewController = [[OtherListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
viewController.title = @"列表3";
viewController = _otherListViewController;
}
break;
@@ -84,6 +117,27 @@
- (void)slideSwitchView:(QCSlideSwitchView *)view didselectTab:(NSUInteger)number
{
DLog(@"%ld",number);
_nowSelectTab = number;
switch (number) {
case 0:
if (_loanListViewController.count <= 0) {
[_loanListViewController headerBeginRefreshing];
}
break;
case 1:
if (_fundListViewController.count <= 0) {
[_fundListViewController headerBeginRefreshing];
}
break;
case 2:
if (_otherListViewController.count <= 0) {
[_otherListViewController headerBeginRefreshing];
}
break;
default:
break;
}
}