iOS 알 리 페 이,위 챗,은 련 결제 통합 패키지 호출(하)

1.점점 더 많은 app 이 제3자 의 기능 을 추가 합 니 다.app 은 서로 다른 페이지 가 있 지만 똑 같은 결제 방식 을 호출 할 수 있 습 니 다.예 를 들 어 화면 은 다음 과 같 습 니 다.

이 두 페이지 는 모두 제3자 결제 결 제 를 사용 합 니 다.(위 챗,알 리 페 이,은 련)만약 에 모든 페이지 에서 제3자 결제 인터페이스 의 모든 코드 를 직접 호출 하면 적당 하지 않 습 니 다.게다가 하나의 app 은 두 개의 입구 가 아 닐 수도 있 습 니 다.그래서 포장 은 필요 합 니 다.
1.새 모델:----백 엔 드 결제 방식 의 목록 json 되 돌려 주기

#import <Foundation/Foundation.h>

@interface IOAPayItemModel : NSObject

//name:      ,  ,       
@property (nonatomic, copy) NSString *name;
//icon:          
@property (nonatomic, copy) NSString *icon;
//code:           
@property (nonatomic, copy) NSString *code;
//payType:      (     )
@property (nonatomic, assign) NSInteger payType;
@end

#import "IOAPayItemModel.h"
@implementation IOAPayItemModel
@end
2.제3자 결제 인터페이스 와 리 셋 인터페이스-직접 소스 코드-설명 이 있 을 것 입 니 다(여러분 의 능력 을 믿 습 니 다.알 아 볼 수 있 을 것 입 니 다)

#import <Foundation/Foundation.h>
//   SDK
#import <AlipaySDK/AlipaySDK.h>
//    
#import <WXApi.h>
//    
#import "UPPaymentControl.h"

/**
   :         
 */
typedef NS_ENUM(NSInteger, PayType) {
 kPayTypeWXPay, //     
 kPayTypeALiPay, //      
 kPayTypeUNPay //     
};


/**
 IOAPayRequestModel:          
 */
@interface IOAPayRequestModel: NSObject
@property (nonatomic, assign) PayType payType;

/**
       -          ----           
 */
@property (nonatomic, copy) NSString *payString;
@property (nonatomic, copy) NSString *appScheme; //      paytype  

/**
   -         ---        
 */
@property (nonatomic, strong) NSDictionary *userInfo;
@end


/**
             ---
 */
@interface IOAPayResponseModel: NSObject
@property (nonatomic, assign) PayType payType;

//result userInfo        --(    、    、     )
@property (nonatomic, assign) NSInteger result;
@property (nonatomic, strong) NSDictionary *userInfo;
@end

@interface IOAPayApi : NSObject

//         
@property (nonatomic, copy) void (^callback)(IOAPayResponseModel *response);

//    model ----IOAPayRequestModel---          
@property (nonatomic, strong) IOAPayRequestModel *payRequestModel;

//    
+ (instancetype)defaultPayManager;

//         
- (BOOL)isPayAppInstalled:(PayType)payType;
//   
- (void)pay:(IOAPayRequestModel *)payRequestModel callback:(void (^)(IOAPayResponseModel *response))callback;

//     
- (void)payCallbackWithUrl:(NSURL *)url;
@end

#import "IOAPayApi.h"

@implementation IOAPayRequestModel

- (void)setPayType:(PayType)payType {
 _payType = payType;
 if (_payType == kPayTypeALiPay) {
 self.appScheme = @"IOAAlipaySDK";
 //   
// self.payString = @"alipay_sdk=1.0&app_id=2018012502067343&biz_content=%7B%22subject%22%3A%22%E6%94%AF%E4%BB%98%E5%AE%9D%E6%94%AF%E4%BB%98%22%2C%22out_trade_no%22%3A%222018032100007%22%2C%22total_amount%22%3A%220.01%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22timeout_express%22%3A%2210m%22%2C%22seller_id%22%3A%222088001065568658%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&notify_url=api.ioa365.net%2Fapp%2Fapi%2FPayment%2Falipay_notify&sign_type=RSA2&timestamp=2018-03-21+16%3A59%3A15&version=1.0&sign=SFyiWFqdkG98qarJFKfNjts8w2RS7ATwjCRyNnKYILDaVVFEnR%2F943QjK9WFaZgipx38rZuRf%2Bl4M74Hp2PO%2F%2F0ZfSKAntTU3DMLIVgt4YD42W1F2lOP3iXtkL5BHpPzt6YfDQueCz1zReeAWQXlyBDvvnjbJ9p67f2jt8jfqM6Enz6kWwY5cShyDD6iJQF0FKXdmSYA%2BiCO6IIHdiqKsRLHuBPb8lfSxJyY1%2FbaAUysIB3%2BiU6HWASUGadCVL769ivwHKwdjZQZUoFpjcfnneyZG3%2B4f%2FnlBrY1pKk3ZWy2UqpTtk0w0GofsF167dRz47J0lW7UufyM8uA%2BIhZ7Lw%3D%3D";
 
 return;
 }
 
 if (_payType == kPayTypeUNPay) {
 self.appScheme = @"UPPay";
 
 //   
// self.payString = @"559018436594292239101";
 
 return;
 }
 
 //   
// self.userInfo = @{
//     @"appid":@"wx66a3135d1354b23b",
//     @"noncestr":@"J8pJbaEg6AjDQ9kk",
//     @"partnerid":@"1497576612",
//     @"prepayid":@"wx20180321170621b3fbce61a20187009040",
//     @"result_code":@"SUCCESS",
//     @"return_code":@"SUCCESS",
//     @"return_msg":@"OK",
//     @"sign":@"29FFF7B63A71D3FB4C6866BDBC443F72",
//     @"timestamp":@"1521623180",
//     @"trade_type":@"APP",
//     };
}
@end

@implementation IOAPayResponseModel

@end

@interface IOAPayApi() <WXApiDelegate>

@end

@implementation IOAPayApi

//    
static IOAPayApi *manager = nil;
+ (instancetype)defaultPayManager {
 static dispatch_once_t onceToken;
 dispatch_once(&onceToken, ^{
 manager = [IOAPayApi new];
 });
 return manager;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
 static dispatch_once_t onceToken;
 dispatch_once(&onceToken, ^{
 manager = [super allocWithZone:zone];
 });
 
 return manager;
}

//copy       copyWithZone:
- (instancetype)copyWithZone:(NSZone *)zone {
 return [[self class] defaultPayManager];
}
+ (instancetype)copyWithZone:(struct _NSZone *)zone {
 return [self defaultPayManager];
}
+ (instancetype)mutableCopyWithZone:(struct _NSZone *)zone {
 return [self defaultPayManager];
}
- (instancetype)mutableCopyWithZone:(NSZone *)zone {
 return [[self class] defaultPayManager];
}

#pragma mark - WeiChatPayDelegate
- (void)onResp:(BaseResp *)resp {
 //       response
 if (self.payRequestModel.payType == kPayTypeWXPay) {
 if (self.callback) {
  IOAPayResponseModel *payResponseModel = [IOAPayResponseModel new];
  payResponseModel.result = 0;
  if([resp isKindOfClass:[PayResp class]]){
  //      ,                 
  switch (resp.errCode) {
   case 0:
//   payResoult = @"    :  !";
   payResponseModel.result = 1;
   break;
   case -1:
   payResponseModel.result = 0;
   break;
   case -2:
   payResponseModel.result = 0;
   break;
   default:
   break;
  }
  }
  
  self.callback(payResponseModel);
 }
 }
}

#pragma mark - Public

//         
- (BOOL)isPayAppInstalled:(PayType)payType {
 switch (payType) {
 case kPayTypeWXPay:
  return [WXApi isWXAppInstalled];
  break;
  
 case kPayTypeALiPay:
  //         NO
  return NO;
  break;
 case kPayTypeUNPay:
  return [[UPPaymentControl defaultControl] isPaymentAppInstalled];
  break;
 default:
  break;
 }
 
 return NO;
}

- (void)pay:(IOAPayRequestModel *)payRequestModel callback:(void (^)(IOAPayResponseModel *response))callback {
 if (!payRequestModel) return;
 self.callback = callback;
 self.payRequestModel = payRequestModel;
 
 switch (payRequestModel.payType) {
 case kPayTypeWXPay:
  [self wxPay:payRequestModel];
  break;
  
 case kPayTypeALiPay:
  [self aliPay:payRequestModel];
  break;
 case kPayTypeUNPay:
  [self unPay:payRequestModel];
  break;
 default:
  break;
 }
}

//     
- (void)payCallbackWithUrl:(NSURL *)url {
 //       SDK   
 if ([url.host isEqualToString:@"safepay"]) {
 [self aliPayCallback:url];
 }
 else if ([url.host isEqualToString:@"pay"]) {
 //          
 [self wxPayCallback:url];
 }
 else if ([url.host isEqualToString:@"uppayresult"]) {
 [self unPayCallback:url];
 }
}

#pragma mark - Pay

//     
- (void)wxPay:(IOAPayRequestModel *)payRequestModel {
 PayReq *req = [[PayReq alloc] init];
 NSDictionary *dataDic = payRequestModel.userInfo;
 //       AppID       ,        
 req.openID = dataDic[@"appid"];
 //   id,        
 req.partnerId = dataDic[@"partnerid"];
 //                    ,             ,         
 req.prepayId = dataDic[@"prepayid"];
 //                
 req.package = @"Sign=WXPay";
 //     ,       ,     
 req.nonceStr = dataDic[@"noncestr"];
 //       ,        ,       
 NSString * stamp = dataDic[@"timestamp"];
 req.timeStamp = stamp.intValue;
 //           
 req.sign = dataDic[@"sign"];
 //       ,      onResp
 [WXApi sendReq:req];
}

//    
- (void)aliPay:(IOAPayRequestModel *)payRequestModel {
 NSString *appScheme = payRequestModel.appScheme;
 NSString *payString = payRequestModel.payString;
 
 __weak __typeof(self)weakSelf = self;
 [[AlipaySDK defaultService] payOrder:payString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
 if (weakSelf.payRequestModel.payType == kPayTypeALiPay) {
  if (weakSelf.callback) {
  IOAPayResponseModel *payResponseModel = [IOAPayResponseModel new];
  payResponseModel.userInfo = resultDic;
  payResponseModel.result = [resultDic[@"result"] integerValue];
  weakSelf.callback(payResponseModel);
  }
 }
 }];
}

//     
- (void)unPay:(IOAPayRequestModel *)payRequestModel {
 NSString *appScheme = payRequestModel.appScheme;
 NSString *payString = payRequestModel.payString;
 [[UPPaymentControl defaultControl] startPay:payString fromScheme:appScheme mode:@"01" viewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}

//////
- (void)wxPayCallback:(NSURL *)url {
 //           ,      
 [WXApi handleOpenURL:url delegate:self];
}

- (void)aliPayCallback:(NSURL *)url {
 __weak typeof(self)weakSelf = self;
 [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
 if (weakSelf.payRequestModel.payType == kPayTypeALiPay) {
  if (weakSelf.callback) {
  IOAPayResponseModel *payResponseModel = [IOAPayResponseModel new];
  payResponseModel.userInfo = resultDic;
  payResponseModel.result = [resultDic[@"result"] integerValue];
  weakSelf.callback(payResponseModel);
  }
 }
 }];
}

- (void)unPayCallback:(NSURL *)url {
 __weak typeof(self)weakSelf = self;
 [[UPPaymentControl defaultControl]handlePaymentResult:url completeBlock:^(NSString *code, NSDictionary *data) {
 if (weakSelf.payRequestModel.payType == kPayTypeUNPay) {
  if (weakSelf.callback) {
  IOAPayResponseModel *payResponseModel = [IOAPayResponseModel new];
  payResponseModel.userInfo = data;
  if ([code isEqualToString:@"success"]) {
   [[NSNotificationCenter defaultCenter] postNotificationName:@"YINLIANPAYS" object:nil];
   payResponseModel.result = [code boolValue];
  }
  else if([code isEqualToString:@"fail"]) {
   //    
   [[NSNotificationCenter defaultCenter] postNotificationName:@"YINLIANPAYF" object:nil];
   payResponseModel.result = [code boolValue];
  }
  else if([code isEqualToString:@"cancel"]) {
   //    
   [[NSNotificationCenter defaultCenter] postNotificationName:@"YINLIANPAYC" object:nil];
   payResponseModel.result = 0;
  }
  
  weakSelf.callback(payResponseModel);
  }
 }
 }];
}
@end
3.이 때 방법 은 봉 하기 시작 합 니 다.필요 한 곳 에서 직접 사용 할 수 있 습 니 다(탄 틀 이 만 들 어 졌 습 니 다)

- (void)alipay{
 [self startProgress];
 self.requestModel.pay_type = @"alipayMobile";
 //       ---                   
 [self.viewModel requestCartSettlePay:self.requestModel callback:^(IOAResponse *response) {
 dispatch_async(dispatch_get_main_queue(), ^{
  [self stopProgress];
  if (response.success) {
  NSString *appScheme = @"IOAAlipaySDK";
  self.payRequestModel.payString = response.responseObject;
  self.payRequestModel.payType = 1;
  self.payRequestModel.appScheme = appScheme;
  //       (  )
  [[IOAPayApi defaultPayManager] pay:self.payRequestModel callback:^(IOAPayResponseModel *response) {
   dispatch_async(dispatch_get_main_queue(), ^{
   NSDictionary *userInfo = response.userInfo;
   if (![userInfo[@"resultStatus"] isEqualToString:@"9000"]) {
    //       (           )
    [self pushWait];
   }else{
    //        (    )
    [self pushList];
   }
   });
  }];
  }else{
  [self.view makeToast:@"    "];
  }
 });
 }];
}
4.무 거 운 파운드 가 왔 습 니 다.(일부 사람들 은 탄 틀 을 만 들 지 않 았 으 니 아래 코드 를 직접 복사 할 수 있 습 니 다)
새 컨트롤 러 제어 탄 상자.h 파일 중

#import <UIKit/UIKit.h>

#import "IOAPayApi.h"
#import "IOAPayItemModel.h"

@interface IOAPayViewController : UIViewController
//         
@property (nonatomic, copy) void (^clickCallback)(NSInteger atIndex);

+ (instancetype)show;
//block    
+ (instancetype)show:(void (^)(NSInteger atIndex))clickCallback;
+ (void)dismiss;

- (void)setupItemTitles:(NSArray <NSString *>*)titles;
- (void)setupItems:(NSArray <IOAPayItemModel *>*)items;

- (void)setupTitle:(NSString *)title;
@end
구현 방법.m 파일 중

#import "IOAPayViewController.h"

#define PayCellHeight 50
#define PaySectionHeaderHeight 44

@interface IOAPayViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) CALayer *maskLayer;

@property (nonatomic, strong) UILabel *titleView;
@property (nonatomic, strong) UIView *payBgView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataSources;

@property (nonatomic, assign) CGFloat payViewHeight;

- (void)showPayView;
- (void)dismissPayView;
@end

@implementation IOAPayViewController

- (void)dealloc {

}

+ (instancetype)show {
 UIViewController *rootvc = [UIApplication sharedApplication].keyWindow.rootViewController;
 
 IOAPayViewController *vc = [IOAPayViewController new];
 [rootvc addChildViewController:vc];
 [rootvc.view addSubview:vc.view];
 
 [vc setupItemTitles:@[@"    ", @"     ", @"    "]];
 [vc showPayView];
 return vc;
}

+ (instancetype)show:(void (^)(NSInteger atIndex))clickCallback {
 IOAPayViewController *vc = [self show];
 vc.clickCallback = clickCallback;
 
 return vc;
}

+ (void)dismiss {
 UIViewController *rootvc = [UIApplication sharedApplication].keyWindow.rootViewController;
 for (UIViewController *vc in rootvc.childViewControllers) {
 if ([vc isKindOfClass:[IOAPayViewController class]]) {
  IOAPayViewController *tempVC = (IOAPayViewController *)vc;
  [tempVC dismissPayView];
  return;
 }
 }
}

- (void)viewDidLoad {
 [super viewDidLoad];
 self.view.backgroundColor = [UIColor clearColor];
 
 self.maskLayer.frame = self.view.bounds;
 [self.view.layer addSublayer:self.maskLayer];
 
 [self.view addSubview:self.payBgView];
// [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
 [super didReceiveMemoryWarning];
 // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView {
 return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 return self.dataSources.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
 id temp = self.dataSources[indexPath.row];
 if ([temp isKindOfClass:[NSString class]]) {
 cell.textLabel.text = temp;
 }
 else {
 IOAPayItemModel *item = temp;
 cell.textLabel.text = item.name;
 }
 cell.textLabel.font = [UIFont systemFontOfSize:18];
 cell.textLabel.textColor = RGB_HEXString(@"#323232");
 cell.selectionStyle = UITableViewCellSelectionStyleNone;
 
 return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
 return PayCellHeight;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
 return self.titleView;
}
- (CGFloat )tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
 return PaySectionHeaderHeight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// IOAPayRequestModel *payRequestModel = [IOAPayRequestModel new];
// payRequestModel.payType = indexPath.row;
//// WS(weakSelf);
//// __weak typeof (self)weakSelf = self;
// __block IOAPayViewController *payVC = self;
// [[IOAPayApi defaultPayManager] pay:payRequestModel callback:^(IOAPayResponseModel *response) {
//// __strong __typeof (weakSelf)strongSelf = weakSelf;
// response.payType = indexPath.row;
// if (payVC.clickCallback) {
//  payVC.clickCallback(response);
//  payVC = nil;
// }
// }];
 
 if (self.clickCallback) {
 self.clickCallback(indexPath.row);
 }
 
 [self dismissPayView];
}

#pragma mark - Touches
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
 [self dismissPayView];
}

#pragma mark - Public
- (void)setupItemTitles:(NSArray<NSString *> *)titles {
 if (!titles.count) {
 return ;
 }
 
 self.payViewHeight = titles.count * PayCellHeight + PaySectionHeaderHeight;
 CGRect frame = self.view.frame;
 frame.size.height = self.payViewHeight;
 self.tableView.frame = frame;
 
 [self.dataSources removeAllObjects];
 [self.dataSources addObjectsFromArray:titles];
 [self.tableView reloadData];
 
 [self setPayViewFrame];
}

- (void)setupItems:(NSArray <IOAPayItemModel *>*)items {
 if (!items.count) {
 return ;
 }
 
 for (IOAPayItemModel *item in items) {
 if ([item.code isEqualToString:@"appWeixinPay"]) {
  item.payType = 0;
  continue;
 }
 
 if ([item.code isEqualToString:@"alipayMobile"]) {
  item.payType = 1;
  continue;
 }
 
 if ([item.code isEqualToString:@"unionpay"]) {
  item.payType = 2;
  continue;
 }
 if ([item.code isEqualToString:@"ye"]) {
  item.payType = 3;
  continue;
 }
 item.payType = 3;
 }
 
 self.payViewHeight = items.count * PayCellHeight + PaySectionHeaderHeight;
 CGRect frame = self.view.frame;
 frame.size.height = self.payViewHeight;
 self.tableView.frame = frame;
 [self.dataSources removeAllObjects];
 [self.dataSources addObjectsFromArray:items];
 [self.tableView reloadData];
 [self setPayViewFrame];
}

- (void)setupTitle:(NSString *)title {
 self.titleView.text = title;
}

#pragma mark - Private
- (void)showPayView {
 [self.view.layer removeAllAnimations];
 CGFloat payBgViewHeight = self.payViewHeight + BottomHeightOffset;
 CGRect frame = self.view.frame;
 frame.origin.y = self.view.frame.origin.y + self.view.frame.size.height;
 frame.size.height = payBgViewHeight;
 self.payBgView.frame = frame;
 
 frame.origin.y = self.view.frame.size.height - payBgViewHeight;
 [UIView animateWithDuration:0.25 animations:^{
 self.payBgView.frame = frame;
 }];
}

- (void)setPayViewFrame {
 CGFloat payBgViewHeight = self.payViewHeight + BottomHeightOffset;
 CGRect frame = self.view.frame;
 frame.origin.y = self.view.frame.origin.y + self.view.frame.size.height;
 frame.size.height = payBgViewHeight;
 frame.origin.y = self.view.frame.size.height - payBgViewHeight;
 self.payBgView.frame = frame;
}

- (void)dismissPayView {
 CGFloat payBgViewHeight = self.payViewHeight + BottomHeightOffset;

 CGRect frame = self.view.frame;
 frame.origin.y = self.view.frame.origin.y + self.view.frame.size.height;
 frame.size.height = payBgViewHeight;
 
 [UIView animateWithDuration:0.25 animations:^{
 self.payBgView.frame = frame;
 } completion:^(BOOL finished) {
 [self.view removeFromSuperview];
 [self removeFromParentViewController];
 }];
}

#pragma mark - Setter / Getter
- (CALayer *)maskLayer {
 if (_maskLayer == nil) {
 _maskLayer = [CALayer layer];
 _maskLayer.backgroundColor = [UIColor blackColor].CGColor;
 _maskLayer.opacity = 0.2;
 }
 
 return _maskLayer;
}

- (UILabel *)titleView {
 if (!_titleView) {
 _titleView = [UILabel new];
 _titleView.textAlignment = NSTextAlignmentCenter;
 _titleView.text = @"       ";
 _titleView.font = [UIFont systemFontOfSize:16];
 _titleView.textColor = [UIColor blackColor];
 _titleView.backgroundColor = RGB_HEXString(@"#f2f2f2");//[UIColor whiteColor];
 }
 
 return _titleView;
}

- (UIView *)payBgView {
 if (!_payBgView) {
 _payBgView = [UIView new];
 _payBgView.backgroundColor = [UIColor whiteColor];
 [_payBgView addSubview:self.tableView];
 }
 return _payBgView;
}

- (UITableView *)tableView{
 if (!_tableView) {
 _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
 _tableView.delegate = self;
 _tableView.dataSource = self;
 _tableView.showsVerticalScrollIndicator = NO;
 _tableView.showsHorizontalScrollIndicator = NO;
 _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
 _tableView.separatorColor = RGB_HEXString(@"#f2f2f2");
 if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
  [_tableView setSeparatorInset:UIEdgeInsetsZero];
 }
 if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
  [_tableView setLayoutMargins:UIEdgeInsetsZero];
 }
 
 //
 [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
 }
 return _tableView;
}

- (NSMutableArray *)dataSources {
 if (!_dataSources) {
 _dataSources = [NSMutableArray array];
 }
 return _dataSources;
}

- (void)setPayViewHeight:(CGFloat)payViewHeight {
 _payViewHeight = payViewHeight;
 CGFloat height = self.view.frame.size.height * 0.6;
 self.tableView.scrollEnabled = NO;
 if (_payViewHeight > height) {
 _payViewHeight = height;
 self.tableView.scrollEnabled = YES;
 }
}
@end
예시 방법
요청 한 데 이 터 를 이용 하여 값 을 부여 합 니 다.

IOAOrderBaseModel *dataSourceModel = self.dataSource[indexPath.section];
  IOAOrderSelectAbleItemModel *itemModel = (IOAOrderSelectAbleItemModel *) dataSourceModel.items[row];
  IOAPayViewController *vc = [IOAPayViewController show:^(NSInteger atIndex) {
  IOAPayItemModel *payItem = itemModel.items[atIndex];
  itemModel.selectedIndex = atIndex;
  
  weakSelf.requestModel.pay_type = payItem.code;
  weakSelf.payItem = payItem;
  
  [weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
  }];
  [vc setupItems:self.confirmOrderInfo.payment_list];
  [vc setupTitle:@"       "];
마지막 으로 예 를 들 어 방법 은 모든 적용 이 아 닙 니 다.위의 1.2.3 에 대해 직접 가 져 가서 사용 할 수 있 습 니 다.이런 것들 은 모두 오리지널 입 니 다.만약 에 첫 번 째 접속 이 라면 여러분 들 이 지난 글 을 읽 고 통합 하 는 전체 과정 을 읽 어 주 십시오.이 코드 의 전체 demo 입 니 다.

좋은 웹페이지 즐겨찾기