EScrollerView制作bannar作为广告栏,可以滑动,点击
1、下载第三方链接:http://download.csdn.net/download/li841538513/6930229
2.将ESCrollerView.h ESCrollerView.m拖至你的工程。
切记:如果你使用的是ARC模式,则需要修改如下图:
在你想要嵌入广告拦的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];
}