9.17. Use of image view

发布时间 :2025-10-25 12:23:53 UTC      

An image view is used to display an image of a single image or animation sequence.

Important attribute

  • Image

  • HighlightedImage

  • UserInteractionEnabled

  • AnimationImages

  • AnimationRepeatCount

9.17.1. An important method

- (id)initWithImage:(UIImage *)image
- (id)initWithImage:(UIImage *)image highlightedImage:
  (UIImage *)highlightedImage
- (void)startAnimating
- (void)stopAnimating

9.17.2. Add a custom method addImageView

-(void)addImageView{
    UIImageView *imgview = [[UIImageView alloc]
    initWithFrame:CGRectMake(10, 10, 300, 400)];
    [imgview setImage:[UIImage imageNamed:@"AppleUSA1.jpg"]];
    [imgview setContentMode:UIViewContentModeScaleAspectFit];
    [self.view addSubview:imgview];
}

Add another custom method addImageViewWithAnimation

This method explains how to animate images in imageView.

-(void)addImageViewWithAnimation{
    UIImageView *imgview = [[UIImageView alloc]
    initWithFrame:CGRectMake(10, 10, 300, 400)];
    // set an animation
    imgview.animationImages = [NSArray arrayWithObjects:
    [UIImage imageNamed:@"AppleUSA1.jpg"],
    [UIImage imageNamed:@"AppleUSA2.jpg"], nil];
    imgview.animationDuration = 4.0;
    imgview.contentMode = UIViewContentModeCenter;
    [imgview startAnimating];
    [self.view addSubview:imgview];
}

注意: 我们必须添加命名为”AppleUSA1.jpg”和”AppleUSA2.jpg”到我们的项目,可以通过将图像拖到我们导航区域,其中列出了我们的项目文件所做的图像。

Update viewDidLoad in ViewController.m, as shown below

(void)viewDidLoad
{
   [super viewDidLoad];
   [self addImageView];
}
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.