Analysis on OpenFlow Programming Based on iPhone SDK Development

Source: Internet
Author: User

IPhone SDKDevelopment BasicsOpenFlowProgramming is a small part of this article. When the user interface needs to display images by PAGE, useOpenFlowFunction provided by the Library, the user interface image to be displayed is displayed on pages, making programming very quick. This Library provides the same visual effects as the OS X desktop Finder program, as shown in 3-46OpenFlowLibrary page by page for the image display program, you can press the screen to scroll around the display, double-click the image to select the currently displayed image,

The program uses the refreshCoverFlow () function in viewDidAppear () of the View Controller to initialize the OpenFlow library and uses the setNumberOfImages () function to set the number of images. The Code is as follows.

 
 
  1. //  RootViewController.m  
  2. - (void)refreshCoverFlow{  
  3.     
  4.  CGRect bounds = [[UIScreen mainScreen] bounds];  
  5.  AFOpenFlowView *coverFlowView = (AFOpenFlowView*)[self.view viewWithTag:kTagCoverflow];  
  6.  if(coverFlowView != nil)  
  7.     [coverFlowView removeFromSuperview];   
  8.  coverFlowView = [[AFOpenFlowView alloc] initWithFrame:CGRectMake(0, -30, bounds.size.width, COVERFLOWHEIGHT)];  
  9.  coverFlowView.dataSource = self;  
  10.  coverFlowView.viewDelegate = self;  
  11.  coverFlowView.defaultImage = [self defaultImage];  
  12.  coverFlowView.tag = kTagCoverflow;  
  13.  [self.view addSubview:coverFlowView];  
  14.  
  15.     NSInteger count = [self numberOfAnimals];  
  16.  [coverFlowView setNumberOfImages:count];  
  17.  //...  
  18.  [coverFlowView release];  

Initialize the image in loadView (), load the image from the resource, and save it in an NSMutableArray variable imageArray. The Code is as follows.

 
 
  1. - (BOOL)doAddAnimal:(NSString *)name Image:(NSString *)imageName{  
  2.    
  3.  UIImage *image = [UIImage imageNamed: imageName];  
  4.  if(image == nil) return FALSE;  
  5.  CGSize size  = CGSizeMake(179, 208);  
  6.  [imageArray addObject:[self resizeImage:image scaledToSize:size]];  
  7.  return TRUE;   

In the requestImageForIndex delegate method of the OpenFlow library, the NSMutableArray index is used directly as the image index of the OpenFlow library. The Code is as follows.

 
 
  1. //  PageViewController.m  
  2. - (void)openFlowView:(AFOpenFlowView *)openFlowView requestImageForIndex: (int)index{  
  3.      UIImage *image =  [imageArray objectAtIndex:index];  
  4.   [openFlowView setImage:image forIndex:index];  

I added the double-click callback INTERFACE IN THE touchesEnded () function of the AFOpenFlowView. m file of the OpenFlow library to notify the caller of the library when double-clicking an image. The Code is as follows.

 
 
  1. //AFOpenFlowView.m  
  2. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {  
  3.  if(((UITouch *)[touches anyObject]).tapCount == 2){  
  4.       if ([self.viewDelegate respondsToSelector:@selector(openFlowView: coverViewDoubleClick:)])  
  5.    [self.viewDelegate openFlowView:self coverViewDoubleClick: selectedCoverView.number];  
  6.     }   
  7.     [super touchesEnded:touches withEvent:event];   

The RootViewController class of the Library can process double-click events by using the interface function coverViewDoubleClick (). The Code is as follows.

 
 
  1. - (void)openFlowView:(AFOpenFlowView *)openFlowView coverViewDoubleClick:(int)index{  
  2.   NSLog(@"coverViewDoubleClick called!");  
  3.   [self showPaintingViewController]; 

Summary: AnalysisIPhone SDKDevelopment BasicsOpenFlowI hope this article will help you with programming!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.