forked from trawor/VZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Travis
committed
Jan 8, 2014
1 parent
574fa6f
commit 25a3551
Showing
5 changed files
with
219 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
1F043A16187C18CC00EFA890 /* VZWebViewC.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F043A15187C18CC00EFA890 /* VZWebViewC.m */; }; | ||
1F0F989118385C2E000CE764 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1F0F989018385C2E000CE764 /* [email protected] */; }; | ||
1F0F989418388E0E000CE764 /* VZCommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F0F989318388E0E000CE764 /* VZCommentCell.m */; }; | ||
1F0F98971838987C000CE764 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1F0F98951838987C000CE764 /* [email protected] */; }; | ||
|
@@ -62,6 +63,8 @@ | |
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
1F043A14187C18CC00EFA890 /* VZWebViewC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VZWebViewC.h; sourceTree = "<group>"; }; | ||
1F043A15187C18CC00EFA890 /* VZWebViewC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VZWebViewC.m; sourceTree = "<group>"; }; | ||
1F0F989018385C2E000CE764 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; }; | ||
1F0F989218388E0E000CE764 /* VZCommentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VZCommentCell.h; sourceTree = "<group>"; }; | ||
1F0F989318388E0E000CE764 /* VZCommentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VZCommentCell.m; sourceTree = "<group>"; }; | ||
|
@@ -259,6 +262,8 @@ | |
1FDF3B20185445450069834B /* VZPostActionC.m */, | ||
1F80240F18797A80005F4005 /* VZStatusListC.h */, | ||
1F80241018797A80005F4005 /* VZStatusListC.m */, | ||
1F043A14187C18CC00EFA890 /* VZWebViewC.h */, | ||
1F043A15187C18CC00EFA890 /* VZWebViewC.m */, | ||
); | ||
name = C; | ||
sourceTree = "<group>"; | ||
|
@@ -430,6 +435,7 @@ | |
1F0F989418388E0E000CE764 /* VZCommentCell.m in Sources */, | ||
1FF2A341183B0D3500731771 /* VZSettingsC.m in Sources */, | ||
1FDD7527181BA4B400F490A3 /* VZPost.m in Sources */, | ||
1F043A16187C18CC00EFA890 /* VZWebViewC.m in Sources */, | ||
1FDD752A181BAE0600F490A3 /* VZPostCell.m in Sources */, | ||
1F4C5C121849B6ED00AB3696 /* VZNavC.m in Sources */, | ||
1F664F8B182375A500DA43F1 /* VZPostViewC.m in Sources */, | ||
|
@@ -536,7 +542,7 @@ | |
isa = XCBuildConfiguration; | ||
baseConfigurationReference = 8B4AF051FD3B4904A6F9F111 /* Pods-VZ.xcconfig */; | ||
buildSettings = { | ||
ARCHS = "$(ARCHS_STANDARD)"; | ||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; | ||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; | ||
CODE_SIGN_IDENTITY = ""; | ||
|
@@ -550,7 +556,7 @@ | |
IPHONEOS_DEPLOYMENT_TARGET = 6.0; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
PROVISIONING_PROFILE = "39BACF4F-15FE-4870-AFA4-326464A0FEFF"; | ||
VALID_ARCHS = "armv7 armv7s"; | ||
VALID_ARCHS = "armv7 armv7s arm64"; | ||
WRAPPER_EXTENSION = app; | ||
}; | ||
name = Debug; | ||
|
@@ -559,7 +565,7 @@ | |
isa = XCBuildConfiguration; | ||
baseConfigurationReference = 8B4AF051FD3B4904A6F9F111 /* Pods-VZ.xcconfig */; | ||
buildSettings = { | ||
ARCHS = "$(ARCHS_STANDARD)"; | ||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; | ||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; | ||
CODE_SIGN_IDENTITY = ""; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// VZWebViewC.h | ||
// VZ | ||
// | ||
// Created by Travis on 14-1-7. | ||
// Copyright (c) 2014年 Plumn LLC. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface VZWebViewC : UIViewController<UIWebViewDelegate> | ||
@property(nonatomic,strong) UIWebView *webView; | ||
|
||
-(void)loadURL:(NSString*)url; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// | ||
// VZWebViewC.m | ||
// VZ | ||
// | ||
// Created by Travis on 14-1-7. | ||
// Copyright (c) 2014年 Plumn LLC. All rights reserved. | ||
// | ||
|
||
#import "VZWebViewC.h" | ||
#import "VZProgressView.h" | ||
#import <StoreKit/SKStoreProductViewController.h> | ||
|
||
#import <SIAlertView/SIAlertView.h> | ||
|
||
@interface VZWebViewC ()<SKStoreProductViewControllerDelegate> | ||
@property(nonatomic,strong) VZProgressView *refreshView; | ||
@end | ||
|
||
@implementation VZWebViewC | ||
|
||
|
||
- (id)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.webView=[[UIWebView alloc] initWithFrame:self.view.bounds]; | ||
[self.view addSubview:self.webView]; | ||
|
||
self.webView.delegate=self; | ||
|
||
self.webView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
|
||
|
||
self.navigationItem.titleView=self.refreshView=[VZProgressView new]; | ||
self.refreshView.progress=1; | ||
|
||
} | ||
|
||
|
||
-(void)loadURL:(NSString*)url{ | ||
NSURLRequest *req=[NSURLRequest requestWithURL:[NSURL URLWithString:url]]; | ||
[self.webView loadRequest:req]; | ||
} | ||
|
||
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ | ||
NSURL *url=request.URL; | ||
if ([url.host hasPrefix:@"itunes.apple.com"]) { | ||
NSRegularExpression *re=[NSRegularExpression regularExpressionWithPattern:@"id([0-9]{8,})" options:0 error:nil]; | ||
NSTextCheckingResult *result= [re firstMatchInString:url.path options:NSMatchingReportCompletion range:NSMakeRange(0, url.path.length)]; | ||
|
||
if (result) { | ||
NSString *storeId=[url.path substringWithRange:[result rangeAtIndex:1]]; | ||
if (storeId) { | ||
__weak typeof(self) ws=self; | ||
|
||
SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init]; | ||
// Configure View Controller | ||
[storeProductViewController setDelegate:(id)self]; | ||
[storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : storeId} | ||
|
||
completionBlock:^(BOOL result, NSError *error) { | ||
if (error) { | ||
NSLog(@"Error %@ with User Info %@.", error, [error userInfo]); | ||
|
||
SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"出错了" andMessage:[error localizedDescription]]; | ||
|
||
[alertView addButtonWithTitle:@"确定" | ||
type:SIAlertViewButtonTypeCancel | ||
handler:^(SIAlertView *alert) { | ||
|
||
}]; | ||
|
||
alertView.transitionStyle = SIAlertViewTransitionStyleDropDown; | ||
|
||
[alertView show]; | ||
|
||
} else { | ||
// Present Store Product View Controller | ||
[self presentViewController:storeProductViewController animated:YES completion:nil]; | ||
} | ||
|
||
ws.refreshView.infinite=NO; | ||
}]; | ||
|
||
self.refreshView.infinite=YES; | ||
return NO; | ||
} | ||
} | ||
|
||
} | ||
|
||
return YES; | ||
} | ||
|
||
-(void)webViewDidStartLoad:(UIWebView *)webView{ | ||
self.refreshView.infinite=YES; | ||
} | ||
|
||
-(void)webViewDidFinishLoad:(UIWebView *)webView{ | ||
self.refreshView.infinite=NO; | ||
} | ||
|
||
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ | ||
self.refreshView.infinite=NO; | ||
|
||
SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"出错了" andMessage:[error localizedDescription]]; | ||
|
||
[alertView addButtonWithTitle:@"确定" | ||
type:SIAlertViewButtonTypeCancel | ||
handler:^(SIAlertView *alert) { | ||
|
||
}]; | ||
|
||
alertView.transitionStyle = SIAlertViewTransitionStyleDropDown; | ||
|
||
[alertView show]; | ||
} | ||
|
||
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { | ||
[self dismissViewControllerAnimated:YES completion:nil]; | ||
} | ||
@end |