技术文章分类(180)

技术随笔(11)

EScrollerView制作bannar作为广告栏,可以滑动,点击

1、下载第三方链接:http://download.csdn.net/download/li841538513/6930229

2.将ESCrollerView.h  ESCrollerView.m拖至你的工程。

切记:如果你使用的是ARC模式,则需要修改如下图:

 
3、配置好SDWebImage。如果你看了这个SDWebImage使用http://www.cnblogs.com/MartinLi841538513/articles/3553059.html,将很有可能节省你很多时间。
 
4.

在你想要嵌入广告拦的viewcontroller.h中

#import "EScrollerView.h"

@interface IndexViewController : UIViewController<EScrollerViewDelegate>

@end

@interfaceIndexViewController ()

{

    NSMutableArray *urls;

@end

 

在viewcontroller.m中

@implementation IndexViewController

 

- (void)viewDidLoad

{

    [superviewDidLoad];

    [selfsetupViews];

}

 

#pragma mark -

- (void)setupViews

{

    EScrollerView *scroller;

    NSMutableArray *imgUrls = [[NSMutableArrayalloc] init];

    urls = [[NSMutableArray alloc] init];

    NSInteger count = 2;

    NSMutableArray *titles = [[NSMutableArrayalloc] init];

    for(int i=0;i<count;i++)

    {

        [urlsaddObject:@"http://dongway.com.cn"];

        [imgUrls addObject:@"http://old.dongway.com.cn/picture/indexdatapic/2013-12/02/220d0bf6-bbf7-4a7e-b27b-80e3fdcaae8b.png"];

        [titles addObject:[NSString stringWithFormat:@"%d",i+1]];

    }

 

    scroller=[[EScrollerView alloc] initWithFrameRect:CGRectMake(0, 0, 320, 150)

                                           ImageArray:imgUrls

                                           TitleArray:titles];

    scroller.delegate=self;

    [self.view addSubview:scroller];

}

 

#pragma mark -

-(void)EScrollerViewDidClicked:(NSUInteger)index

{

    NSString *urlString;

    if(index == urls.count+1)

    {

        urlString = [urls objectAtIndex:0];

    }

    else

    {

        urlString = [urls objectAtIndex:index - 1];

    }

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    WebViewController *webViewController = [[WebViewControlleralloc] init];

    webViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"WebViewController"];

    [self.navigationController pushViewController:webViewController animated:YES];

 

}

3、配置好SDWebImage。如果你看了这个SDWebImage使用http://www.cnblogs.com/MartinLi841538513/articles/3553059.html,将很有可能节省你很多时间。
posted @ 2014-02-17 19:04  坤哥MartinLi  阅读(253)  评论(0编辑  收藏  举报