你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios 一個不錯的圖片浏覽分享框架demo

ios 一個不錯的圖片浏覽分享框架demo

編輯:IOS開發綜合

demo功能:一個不錯的圖片浏覽分享框架demo。iphone6.1 測試通過。可以浏覽圖片,保存,微博分享到新浪,騰訊,網易,人人等。

注:(由於各個微博的接口有時候會有調整,不一定能分享成功。只看框架,在找最新的官方分享接口將信息分享出去)

 


demo說明:主要代碼在:PhotoViewController.m中。分享的各個接口在ShareSDK文件夾下。

框架用到了“SVProgressHUD” 第三方的控件來彈出提示層,提示 網絡加載 或 提示對錯。SVProgressHUD的具體說明;

和 “SDWebImage”類庫來管理遠程圖片加載。SDWebImage的相關說明;

 
demo主要代碼:   主窗口布局部分

- (void)viewDidLoad  
{  
    [super viewDidLoad];  
    self.navigationItem.title = dNaviTitle;  
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];  
    self.navigationController.navigationBarHidden = YES;  
    self.navigationController.navigationBar.translucent = YES;  
    [[UIApplication sharedApplication] setStatusBarHidden:YES];  
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];  
    //self.navigationController.navigationBar.alpha = 0.5f;//將透明度設為50%。  
    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];  
    UIBarButtonItem *saveBarBtn = [[UIBarButtonItem alloc] initWithImage:dPicModuleImageSave style:UIBarButtonItemStylePlain target:self action:@selector(saveImage)];  
    UIBarButtonItem *spaceFlexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];  
    spaceFlexItem.width = 20.0;  
    //分享按鈕  
    UIBarButtonItem *shareBarBtn = [[UIBarButtonItem alloc] initWithImage:dPicToolShare style:UIBarButtonItemStylePlain target:self action:@selector(shareImage)];  
      
    NSArray *barBtnArray = [NSArray arrayWithObjects:spaceItem, saveBarBtn, spaceFlexItem, shareBarBtn, nil];  
    [self setToolbarItems:barBtnArray];  
    self.navigationController.toolbar.tintColor = [UIColor blackColor];  
    self.navigationController.toolbar.translucent = YES;  
    self.navigationController.toolbarHidden = YES;  
      
    [self setWantsFullScreenLayout:YES];  
    //圖片數組  
    _imageURLArray = [[NSMutableArray alloc]initWithObjects:  
                      @"http://jpp1.imghb.com/pic/pic/69/90/24/1410827669902478_a602x602.jpg",  
                      @"http://jpp1.imghb.com/pic/pic/62/21/20/1396500062212039_a602x602.jpg",  
                      @"http://jpp1.imghb.com/pic/pic/87/42/85/1405532187428506_a602x602.jpg",  
                      @"http://jpp1.imghb.com/pic/pic/99/43/0/1392392199430020_a602x602.jpg",  
                      @"http://jpp2.imghb.com/pic/pic/45/48/1/1399381845480110_a602x602.jpg",  
                      @"http://jpp2.imghb.com/pic/pic/49/50/84/1407448049508416_a602x602.jpg",  
                      @"http://jpp2.imghb.com/pic/pic/88/82/83/1402371388828392_a602x602.jpg",  
                      @"http://jpp2.imghb.com/pic/pic/94/37/71/1401133494377186_a602x602.jpg",  
                      @"http://jpp2.imghb.com/pic/pic/88/35/25/1401128288352593_a602x602.jpg", nil];  
      
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];  
    [_scrollView setContentSize:CGSizeMake(320*[_imageURLArray count], 480)];  
    if ([UIScreen mainScreen].bounds.size.height >= 568)//iPhone5適配  
    {  
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];  
        [_scrollView setContentSize:CGSizeMake(320*[_imageURLArray count], 568)];  
    }  
    _scrollView.pagingEnabled = YES;//設為YES時,會按頁滑動  
    _scrollView.bounces = NO;//取消UIScrollView的彈性屬性,這個可以按個人喜好來定  
    [_scrollView setDelegate:self];//UIScrollView的delegate函數在本類中定義  
    _scrollView.showsHorizontalScrollIndicator = YES;  
      
    _scrollView.minimumZoomScale=0.1;  
    _scrollView.maximumZoomScale=4.0;  
      
    [self.view addSubview:_scrollView];  
    [self configScrowViewWithIndex:self.itemIndex withForward:NO withOrigin:YES];  
    pageIndex = itemIndex;  
    _isBarShown = NO;  
}  


 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved