内置视图-滚动视图
来源:互联网 发布:打印出库单软件 编辑:程序博客网 时间:2024/05/22 16:06
interface AppDelegate : UIResponder <UIApplicationDelegate, UIScrollViewDelegate>
@property (nonatomic,retain) UIWindow* window;
@property (nonatomic,retain) UIImageView* mapImageView;
@end
#import "AppDelegate.h"
@implementationAppDelegate
@synthesize window = _window;
@synthesize mapImageView = _mapImageView;
- (void)dealloc
{
self.mapImageView =nil;
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
_window = [[UIWindowalloc] initWithFrame:[UIScreenmainScreen].bounds];
//创建图片视图,显示整张北京地图
_mapImageView = [[UIImageViewalloc] initWithImage:
[UIImage imageNamed:@"BeijingMap.png"]];
//创建一个滚动视图
UIScrollView* scrollView = [[UIScrollViewalloc] initWithFrame:
[UIScreenmainScreen].applicationFrame];
//设置滚动视图要显示的整个地图的尺寸
scrollView.contentSize = self.mapImageView.frame.size;
//滚动视图的初始查看位置为地图的正中央
scrollView.contentOffset =CGPointMake(
(self.mapImageView.frame.size.width - scrollView.frame.size.width)/2,
(self.mapImageView.frame.size.height - scrollView.frame.size.height)/2);
//计算横纵方向上的缩放比例
float ratioX = scrollView.frame.size.width/self.mapImageView.frame.size.width;
float ratioY = scrollView.frame.size.height/self.mapImageView.frame.size.height;
//设置滚动视图的最小与最大缩放比例
scrollView.minimumZoomScale = ratioX > ratioY?ratioX: ratioY;
scrollView.maximumZoomScale = 2;
//设置滚动视图的委托对象
scrollView.delegate = self;
[scrollView addSubview:self.mapImageView];
[self.windowaddSubview:scrollView];
[scrollView release];
[self.windowmakeKeyAndVisible];
return YES;
}
//返回待缩放的视图
- (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView
{
return self.mapImageView;
}
@end- 内置视图-滚动视图
- UIScrollView -滚动视图
- 滚动视图
- 滚动视图
- 滚动视图
- 滚动视图
- UI-滚动视图(滚动视图)
- 滚动视图和网页视图
- Android视图之滚动视图
- Oracle 内置视图
- 4. android 滚动视图
- 滚动视图双缓冲
- 滚动视图二
- UIScrollView 滚动视图
- 滚动视图 ScrollView
- UIScrollView 滚动视图
- UIScrollView 滚动视图
- UIScrollView 滚动视图
- 6.4.5 final方法
- HPL formica plywood,BS1088 marine plywood,H timber beam
- hdu 产生冠军(充分理解题意)
- window下oralce10G使用dblink连接到mysql
- 用java写的一个简易记事本
- 内置视图-滚动视图
- CAS指令 incrementAndGet方法 JAVA非阻塞同步
- uitableview
- 面试:机器学习--支持向量机
- Object转XML && XML转Object
- 关于Bundle及其在不同activity之间的传值
- CSUOJ--1563: Lexicography
- Android的生命周期(三)
- opencv findContours使用问题