IOS project learning summary

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Is a picture display items, only now discovered, pre project planning is very important, this paper records the project problems encountered in development,

The realization of the 1 animation, floating around in the interface of the dandelion, the simple use of animation and the function of time NStimer uiview implementation, the code is as follows:

      puGongYingTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(runPuGongYing) userInfo:nil repeats:NO];//Time function
bigPuGongYingGif =[[GifView alloc] initWithFrame:CGRectMake(-20, 50, 45,46) filePath:[[NSBundle mainBundle] pathForResource:@"pugongying" ofType:@"png"]];
//The above is the realization of GIf picture start animation to achieve       

    [bgView addSubview:bigPuGongYingGif]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:50]; int startX = round(random() % 900);//Random path int endX = round(random() % 700); NSLog(@"startX===%d endX===%d",startX,endX); bigPuGongYingGif.frame=CGRectMake(1025, endX, 45, 46); [UIView setAnimationDidStopSelector:@selector(runPuGongYingAgain)];//Recursive call [UIView commitAnimations];

  

The 2 page in which the appdelegate jump method, the first set is empty, then set to VC

   self.window.rootViewController=Nil;,,

PingBao_PageViewController *pic_page=[[PingBao_PageViewController alloc]init];

self.window.rootViewController=pic_page;

3 app not to let the automatic lock screen [UIApplication sharedApplication].idleTimerDisabled=YES;

Very useful to use 4 single mode, to give an example, after use

#import <Foundation/Foundation.h>

@interface DataPist : NSObject{
    NSMutableDictionary *arryData;
}
@property(nonatomic,strong)NSMutableDictionary *arryData;
@property(nonatomic,strong)NSArray *jianBaoArry;
@property(nonatomic,strong)NSString *ipString;

+(DataPist *) shared;
+(id) allocWithZone:(NSZone *)zone;
+(NSData*)stringToByte:(NSString*)string;
+(void)showLoading;
+(void)hideLoading;
+ (NSString *)dataFilePath ;
@end

#import "DataPist.h"

@implementation DataPist
@synthesize arryData,jianBaoArry,ipString;
static DataPist *ShareDataPist = nil;

+(DataPist *) shared{
    
    @synchronized(self)
    {
        if (ShareDataPist == nil)
        {
            ShareDataPist = [[self alloc] init] ;
            
        }
    }
    return ShareDataPist;
}

+(id) allocWithZone:(NSZone *)zone
{
    @synchronized(self)
    {
        if (ShareDataPist == nil)
        {
            ShareDataPist = [super allocWithZone:zone];            
            return ShareDataPist;
        }
    }  
    return nil;
}

//Transcoding function into 16 check image converter NSData
+(NSData*)stringToByte:(NSString*)string
{
    NSString *hexString=[[string uppercaseString] stringByReplacingOccurrencesOfString:@" " withString:@""];
    if ([hexString length]%2!=0) {
        return nil;
    }
    Byte tempbyt[1]={0};
    NSMutableData* bytes=[NSMutableData data];
    for(int i=0;i<[hexString length];i++)
    {
        unichar hex_char1 = [hexString characterAtIndex:i]; ////The first two digit hexadecimal number 16 in the (high *16)
        int int_ch1;
        if(hex_char1 >= '0' && hex_char1 <='9')
            int_ch1 = (hex_char1-48)*16;   //// 0 Ascll - 48
        else if(hex_char1 >= 'A' && hex_char1 <='F')
            int_ch1 = (hex_char1-55)*16; //// A Ascll - 65
        else
            return nil;
        i++;
        
        unichar hex_char2 = [hexString characterAtIndex:i]; ///Two digit hexadecimal number 16 in the second (low)
        int int_ch2;
        if(hex_char2 >= '0' && hex_char2 <='9')
            int_ch2 = (hex_char2-48); //// 0 Ascll - 48
        else if(hex_char2 >= 'A' && hex_char2 <='F')
            int_ch2 = hex_char2-55; //// A Ascll - 65
        else
            return nil;
        
        tempbyt[0] = int_ch1+int_ch2;  ///The converted number into the Byte array
        [bytes appendBytes:tempbyt length:1];
    }
    return bytes;
}
+(void)showLoading{
//    [[UIApplication sharedApplication].windows objectAtIndex:0]
    
       [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication].windows objectAtIndex:0] animated:YES];
//    mb.labelText=@"Loading";
}
+(void)hideLoading{
    [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication].windows objectAtIndex:0] animated:YES];

}
+ (NSString *)dataFilePath {
    //Write library
    NSString *path=[NSHomeDirectory() stringByAppendingPathComponent:@"Library"];
    
    NSString *pathNext = [NSString stringWithFormat:@"%@/Caches",path];
    NSString *fileNamepath=[pathNext stringByAppendingPathComponent:@"Image.plist"];
    return fileNamepath;
}
@end

5  Download multiple zip image, then extract, in the specified directory, implementation

Download implementation:

 //Macro definition sandbox directory#define DocumentsDirectory [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) lastObject]
-(void)download{
    mb.labelText=@"Downloading";
    // Initialize the queue
    if (!networkQueue) {
        networkQueue = [[ASINetworkQueue alloc] init];
        // Set the maximum number of concurrent -1 as default unrestricted
        [networkQueue setMaxConcurrentOperationCount:-1];
    }
    // Re queue
    [networkQueue cancelAllOperations];
    [networkQueue reset];
    // The progress bar set the queue
    [networkQueue setDownloadProgressDelegate:progressView];
    // Set up method
    [networkQueue setRequestDidFailSelector:@selector(Failed:)];//A failed download execution
    [networkQueue setQueueDidFinishSelector:@selector(Succeed:)];//Regardless of success or failure will execute Download
    [networkQueue setRequestDidFinishSelector:@selector(Finished:)];//A successful implementation
    // Display the exact schedule
    [networkQueue setShowAccurateProgress:YES];
    [networkQueue setDelegate:self];
    ASIHTTPRequest *request;
    //Zip_names from the server zipname address
    for (int i=0; i<[zip_names count]; i++) {
        NSString *name=[zip_names objectAtIndex:i];
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/api/%@.zip",[DataPist shared].ipString,name]];
        request = [ASIHTTPRequest requestWithURL:url];

     [request setTemporaryFileDownloadPath:[DocumentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip.temp",[zip_names objectAtIndex:i]]]]; [request setDownloadDestinationPath:[DocumentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",[zip_names objectAtIndex:i]]]]; [request setAllowResumeForFileDownloads:YES]; [networkQueue addOperation:request]; } [networkQueue go]; } -(void)Succeed:(ASINetworkQueue *)request{ if (Flag != NO) { [self performSelector:@selector(changeloading) withObject:self afterDelay:0]; [self jieya]; } } -(void)Finished:(ASIHTTPRequest *)request{ } -(void)changeloading{ mb.labelText=@"Initializing data ";} - (void) Failed: (ASIHTTPRequest *) request{Flag = NO; // a failed download settings for no, Will not be executedSucceed:(ASINetworkQueue *)requestDecompression method. if (IsFail==NO) { [ MBProgressHUD hideHUDForView:self.view animated:YES]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Prompt" message:@"Network update failed, Please re download the "delegate:nil cancelButtonTitle:@" "otherButtonTitles:Nil nil] [alert, determined; show]; IsFail=YES; to yes, He is only executed once, } progressView.hidden=YES; [ MBProgressHUD hideHUDForView:self.view animated:YES]; }

//IsFail=NO failed to download, in order not to let the download failure pop-up box repeat;

//Flag = YES;Role is to show only the download success after started the implementation of Succeed: (ASINetworkQueue *) request inside, this is their initialization value,

//When after the failure, and the start of their initialization data, IsFail=no, Flag=yes

//Decompression method

- (void)jieya{

   To use the zipArchive class library

ZipArchive *zip=[[ZipArchive alloc]init];

for (int i = 0; i <zip_names.count; i++) {

NSString *name = [NSString stringWithFormat:@"Documents/%@.zip",[zip_names objectAtIndex:i]];

NSString *path=[NSHomeDirectory()stringByAppendingPathComponent:[NSString stringWithString:name]];

NSLog(@"-----%@",path);

NSString *unZipTo;

NSString *rang=[zip_names objectAtIndex:i];

     // This is in order to find the download of the zip is that, and then separated into different folders.,

if (([rang rangeOfString:@"large"].location!=NSNotFound)) {

unZipTo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/bigImage"];

}else{

unZipTo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

}

if ([zip UnzipOpenFile:path])

{

[zip UnzipFileTo:unZipTo overWrite:YES];

[zip UnzipCloseFile];

}

}

if ([[zip_names objectAtIndex:0] rangeOfString:@"small"].location!=NSNotFound||[[zip_names objectAtIndex:0] rangeOfString:@"publicimg"].location!=NSNotFound) {

[self writer];

}else{

NSLog(@"Do not need to write.");


}

Method to write, think at that time is well put the pictures to the plist file.,

-(void)writer{

//The path to the application sandbox.

//

NSArray *paths = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];

//Read the existence of sandbox inside the file.

for (int i = 0; i <zip_names.count; i++) {

if ([[zip_names objectAtIndex:i] isEqualToString:@"publicimg"] || [[zip_names objectAtIndex:i] isEqualToString:@"uppublicimg"]) {

NSString *imgPath1=[NSHomeDirectory()stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@.json",[zip_names objectAtIndex:i]]];

////Because get a path to load it into a data object

NSData *data=[NSData dataWithContentsOfFile:imgPath1];

NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:NULL];

//Judge whether the correct login

//

NSString *str = [NSString stringWithFormat:@"%@",[weatherDic objectForKey:@"flag"]];

//Remove all the picture information

NSDictionary *season = [weatherDic objectForKey:@"season_img"];

NSDictionary *season_line = [weatherDic objectForKey:@"line_season_img"];

//

NSDictionary *report_img = [weatherDic objectForKey:@"report_img"];

NSDictionary *screen_img = [weatherDic objectForKey:@"screen_img"];

//

NSLog(@"%@,%@,%@,%@,%@",wirte,season,season_line,report_img,screen_img);

//

NSDictionary *line_name = [NSDictionary alloc];

//Write plist

//

NSString *filePath = [self dataFilePath];

if ([DataPist shared].arryData ==Nil) {To determine whether arryData exists, not exists, from the newly created file path

[DataPist shared].arryData = [[NSMutableDictionary alloc]init];

}

if ([[NSFileManager defaultManager] fileExistsAtPath:[self dataFilePath]]) {

[DataPist shared].arryData  = [[NSMutableDictionary alloc]initWithContentsOfFile:[self dataFilePath]];

}

NSFileManager* fm = [NSFileManager defaultManager];

[fm createFileAtPath:[self dataFilePath] contents:nil attributes:nil];

if (![[NSString stringWithFormat:@"%@",[season objectForKey:@"img_null"]] isEqualToString:@"0"]) {

[ [DataPist shared].arryData  setValuesForKeysWithDictionary:season];//This setValue DIC is written directly inside plsit added, he will automatically written to the key value,

}

if (![[NSString stringWithFormat:@"%@",[season_line objectForKey:@"img_null"]] isEqualToString:@"0"]) {

[ [DataPist shared].arryData  setValuesForKeysWithDictionary:season_line];

}

//

if (![[NSString stringWithFormat:@"%@",[report_img objectForKey:@"img_null"]] isEqualToString:@"0"]) {

//

[ [DataPist shared].arryData  setValuesForKeysWithDictionary:report_img];

//

}

if (![[NSString stringWithFormat:@"%@",[screen_img objectForKey:@"img_null"]] isEqualToString:@"0"]) {

[ [DataPist shared].arryData  setValuesForKeysWithDictionary:screen_img];

}

}

else if([[zip_names objectAtIndex:i] rangeOfString:@"small"].location!=NSNotFound){

NSString *imgPath1=[NSHomeDirectory()stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@.json",[zip_names objectAtIndex:i]]];

////Because get a path to load it into a data object

NSData *data=[NSData dataWithContentsOfFile:imgPath1];

NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:NULL];

NSDictionary *img_name = [weatherDic objectForKey:@"line_img"];

if (![[NSString stringWithFormat:@"%@",[img_name objectForKey:@"img_null"]] isEqualToString:@"0"]) {

[ [DataPist shared].arryData  setValuesForKeysWithDictionary:img_name];

}

}else{

}

[ [DataPist shared].arryData  setValue:line_img forKey:@"line_name"];

//-------------------

[ [DataPist shared].arryData  setValue:screen_id forKey:@"screen_id"];

[ [DataPist shared].arryData  writeToFile:[self dataFilePath] atomically:YES];

}

isDown=@"1";

[self downLoadAgain];

[DataPist hideLoading];

Choose_LineViewController *choose_Line = [[Choose_LineViewController alloc]init];

[[NSUserDefaults standardUserDefaults] setObject:leftrightImageUrl forKey:@"leftOrRightUrl"];

choose_Line.urlDic=leftrightImageUrl;

[self presentViewController:choose_Line animated:YES completion:Nil];

}

//After the success of the judge

-(void)downLoadAgain{

NSString *uuid = [[UIDevice currentDevice] uniqueIdentifier];

NSString *post = [NSString stringWithFormat:@"%@/api/flag.php?uid=%@&status=%@",[DataPist shared].ipString,uuid,isDown];

NSURLRequest *request111 = [NSURLRequest requestWithURL:[NSURL URLWithString:post]];

NSData *response = [NSURLConnection sendSynchronousRequest:request111 returningResponse:nil error:nil];

//

update_flg=@"1";

//

[[NSUserDefaults standardUserDefaults]setObject:update_flg forKey:@"update_flg"];

}

It mainly used in the conventional method, and a powerful BOOl variables, can judge many things method is implemented, then remember to use,

6: Popup view iPad above in the following way: this week, similar to the QQ pop-up interface

 Setting_PageViewController *setting_page = [[Setting_PageViewController alloc]init];
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:setting_page];
    nav.modalPresentationStyle=UIModalPresentationFormSheet;
    [self presentViewController:nav animated:YES completion:NULL];

If the pop-up interface with multi view, which can be used in the push, (using tableView method)

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        switch (indexPath.row) {
            case 0:
            {
                ScreenSaveAnimation_ViewController *SV=[[ScreenSaveAnimation_ViewController alloc]init];
                [self.navigationController pushViewController:SV animated:YES];
            }
                break;
            case 1:{
                ScreenSaveType_ViewController *ST=[[ScreenSaveType_ViewController alloc]init];
                [self.navigationController pushViewController:ST animated:YES];
                
            }break;
                
            default:
                break;
        }

Push in view, return can also return [self.navigationController popViewControllerAnimated:YES];

In the tableview int n=[indexPath indexAtPosition:0]; can be taken to the location of the section, Inside the didSelectRowAtIndexPath method is mainly used in tableview, When clicking on this way, In order to display a mark in the list on the left side of the words, You can start when the mark is added in each rows button, To hide away, Set tag, Then, Click on the time by tag let him show up, Is the first to traverse the tableview on the view all over again, Hide, Then you click on the view tag, Let him show, The other would have hidden the, Such code

-(void)nextTag:(NSIndexPath *)indexPath{
    
    UIImageView *image;
    
    int n=[indexPath indexAtPosition:0];//Distinguish section
    if (n==0) {
        for (int i=500; i<540; i++) {//The first full circulation hide, 
            image=(UIImageView *)[self.view viewWithTag:i];
            [image setHidden:YES];
        }
        image=(UIImageView *)[self.view viewWithTag:indexPath.row+500];//A display
        image.hidden=NO;
        
    }else if (n==1){
        
        for (int i=500; i<540; i++) {
            image=(UIImageView *)[self.view viewWithTag:i];
            [image setHidden:YES];
        }
        image=(UIImageView *)[self.view viewWithTag:indexPath.row+510];
        image.hidden=NO;
        
    }else if (n==2){
        
        for (int i=500; i<540; i++) {
            image=(UIImageView *)[self.view viewWithTag:i];
            [image setHidden:YES];
        }
        image=(UIImageView *)[self.view viewWithTag:indexPath.row+520];
        image.hidden=NO;
        
    }else if (n==3){
        
        for (int i=500; i<540; i++) {
            image=(UIImageView *)[self.view viewWithTag:i];
            [image setHidden:YES];
        }
        
        image=(UIImageView *)[self.view viewWithTag:indexPath.row+530];
        image.hidden=NO;
    }
    
}

7 button display method of the squares of the,

-(void)initImage:(int)number
{ This method is mainly used for today on Scrollview pages display pictures, 
    int num = line_detailInfo.count - number*10;//Judge line_detailInfo is always a few pictures, 
    //Num11 number of rows
    int num11 = 0;
    //Num22 determine the column number
    int num22 = 0;
    
    if (num > 5) {
        num11 = 2;
    }else if(num <= 5 ){
        num11 = 1;
    }
    for (int M=0; M <num11; M++) {
        if (num >= 5) {
            num22 = 5;
        }else if(num <5){
            num22 = num%5;
        }
        for (int i=0; i <num22; i++) {
            UIButton *btns = [UIButton buttonWithType:0];
//            [btns setImage:[UIImage imageNamed:[NSString stringWithFormat:@"a_%d.png",i]] forState:UIControlStateNormal];
            NSString *str;
            if (M == 0) {
               str  = [line_detailInfo objectAtIndex:i+number*10];
            }else if (M == 1){
                str  = [line_detailInfo objectAtIndex:i+number*10+5];
            }
            
            NSString *img_data = [NSString stringWithFormat:@"%@",[[DataPist shared].arryData objectForKey:[NSString stringWithFormat:@"s%@",str]]];
            [btns setImage:[UIImage imageWithData:[DataPist stringToByte:img_data]] forState:UIControlStateNormal];//Show the picture
            if (M == 0) {
                btns.tag = i+number*10+100;
            }else if (M == 1){
                btns.tag = i+number*10+5+100;
            }
            
            [btns addTarget:self action:@selector(goNext:) forControlEvents:UIControlEventTouchUpInside];
            btns.frame = CGRectMake(1024*number+99+i*130+i*45,M*230+41*M+70, 130,230);
            [scroll addSubview:btns];
        }
        num = num - 5;
    }
}

The following methods are mainly displayed on top of the Scrollview when loaded to the next page, not loaded when you back

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  int  n=scrollView.contentOffset.x/1024;
    if (n >= scor) {
        scor = n;
        [self initImage:n];
    }
}

Scrollview display with multiple pictures, similar to the picture browser

  scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 82, 1024, 630)];
    scroll.backgroundColor=[UIColor clearColor];
    scroll.showsVerticalScrollIndicator=NO;
    scroll.pagingEnabled=YES;
    scroll.delegate=self;
    scroll.showsVerticalScrollIndicator = FALSE;
    scroll.showsHorizontalScrollIndicator = FALSE;
    [self.view addSubview:scroll];The underlying Scrollview for sliding and page using
  

//This MRZoomScrollView is mainly used to display images and zoom

for (int i = 0; i <imageArrys.count; i++) { zoomScrollView = [[MRZoomScrollView alloc]init]; CGRect frame = scroll.frame; zoomScrollView.maximumZoomScale=2; zoomScrollView.minimumZoomScale=1; zoomScrollView.tag=2000+i; zoomScrollView.showsVerticalScrollIndicator = NO; zoomScrollView.showsHorizontalScrollIndicator=NO; // zoomScrollView.backgroundColor=[UIColor grayColor]; frame.origin.x = frame.size.width * i; frame.origin.y = 0; zoomScrollView.frame = frame; [scroll addSubview:zoomScrollView]; } scroll.contentSize=CGSizeMake(1024*imageArrys.count, 768);Set the picture the total number of [scroll setContentOffset:CGPointMake (1024*currentNum, 0) animated:YES]; // set by clicking the small map into larger when scroll remain in that position.

MRZoomScrollView custom classes showed a picture of Scrollview

@interface MRZoomScrollView : UIScrollView <UIScrollViewDelegate>

{

UIImageView *imageView;

}

@property (nonatomic, retain) UIImageView *imageView;

@end

#import "MRZoomScrollView.h"

#define MRScreenWidth

CGRectGetWidth([UIScreen mainScreen].applicationFrame)

#define MRScreenHeight

CGRectGetHeight([UIScreen mainScreen].applicationFrame)

@interface MRZoomScrollView (Utility)

- (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center;

@end

@implementation MRZoomScrollView

@synthesize imageView;

- (id)initWithFrame:(CGRect)frame

{

self = [super initWithFrame:frame];

if (self) {

self.delegate = self;

self.frame = CGRectMake(0, 0, MRScreenWidth, MRScreenHeight);

[self initImageView];

}

return self;

}

- (void)initImageView

{

imageView = [[UIImageView alloc]init];

// The imageView can be zoomed largest size

imageView.frame = CGRectMake(224, 0, 576, 768);

imageView.userInteractionEnabled = YES;

[self addSubview:imageView];

   }

#pragma mark - Zoom methods

- (void)scrollViewDidZoom:(UIScrollView *)scrollView

{

NSLog(@"------%@",NSStringFromCGSize(scrollView.contentSize));

CGFloat offsetX = (scrollView.bounds.size.width > scrollView.contentSize.width)?

(scrollView.bounds.size.width - scrollView.contentSize.width) * 0.5 : 0.0;

CGFloat offsetY = (scrollView.bounds.size.height > scrollView.contentSize.height)?

(scrollView.bounds.size.height - scrollView.contentSize.height) * 0.5 : 0.0;

//

if (YES) {

imageView.center = CGPointMake(scrollView.contentSize.width * 0.5 + offsetX,

scrollView.contentSize.height * 0.5 + offsetY);

}

#pragma mark - UIScrollViewDelegate

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

return imageView;

}

#pragma mark - View cycle

@end

The main method for display to implement the party Scrollview sliding over a screen.,

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

if (scrollView.contentOffset.x>1024*n||scrollView.contentOffset.x<=1024*(n-1)) {//To determine whether the sliding screen

n=scrollView.contentOffset.x/1024;

[self initImage:n];

}

}

Apple's own simple network request method and analytical data

-(void)getInfoImage{
    NSString *urlString = [NSString stringWithFormat:@"%@/api/model_style.php?img_name=%@",[DataPist shared].ipString,[imageArrys objectAtIndex:tags]];
    
    NSURLResponse *urlResponce=nil;
    NSError *error=nil;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
    NSData *Data=[NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponce error:&error];
    if (error) {
        [DataPist hideLoading];
        UIAlertView *alter=[[UIAlertView alloc]initWithTitle:@"Prompt" message:@"The current network is not available, please try again later." delegate:self cancelButtonTitle:@"Determine" otherButtonTitles:nil, nil];
        [alter show];
        return;
    }
    
    NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData:Data options:NSJSONReadingMutableLeaves error:nil];

And when the sliding time to remove some of the value of the control, in order to prevent overlap, let him from the new show, if compared with viewwithtag trouble, can use simple to need from the new assignment control into a view, and then removed from the view, the new view from the new assignment,

8: If the client needs to query image classification method. The general situation is the need for database support, but for the sake of convenience, can click on a button, the server requests like hair, the server returns to the picture display, and then the client received the picture, then the query in the sandbox, so fast, is relatively simple, are shown in the following simple sandbox pictures in it

  NSString *name=[NSString stringWithFormat:@"%@",[imageArrys objectAtIndex:tags]];Picture name
    NSString *ss=[NSString stringWithFormat:@"Documents/bigImage/%@",name];
    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",ss]];The image path
    NSString *fileName=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];/Load the image into a string,
    NSString *imageNames=[fileName stringByReplacingOccurrencesOfString:@"-" withString:@"1"];//The string to decrypt the encrypted image

9 Video loads used is AVQueuePlayer, a simple code.

//Initialize the player assembly
-(void)initPlayer
{
    [arryItems removeAllObjects];
    
    for (int i = 0; i <34; i++) {
        [arryMp3Name addObject:[NSString stringWithFormat:@"Sequence %@",[arryImages objectAtIndex:i]]];
    }    for (NSString *text in arryMp3Name) {
        NSURL *playerFileURL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:text ofType:@"mp4"]];
        AVPlayerItem *item=[AVPlayerItem playerItemWithURL:playerFileURL];
        [arryItems  addObject:item];
    }
//    NSLog(@"arryItems==%d",arryItems.count);
    //Add the notification of playing next song
    for (int songPointer = 0; songPointer <[arryItems count]; songPointer++) {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(songEnded:)
                                                     name:AVPlayerItemDidPlayToEndTimeNotification
                                                   object:[arryItems objectAtIndex:songPointer]];
    }
    
    queuePlayer = [AVQueuePlayer queuePlayerWithItems:arryItems];
    playLayer = [AVPlayerLayer playerLayerWithPlayer:queuePlayer];
    playLayer.frame = CGRectMake(0, 82, 1024, 576);
    [self.view.layer addSublayer:playLayer];
    [queuePlayer play];
    
    playerView=[[UIView alloc]initWithFrame:CGRectMake(0,90, 1024, 576)];
    playerView.backgroundColor=[UIColor clearColor];
    playerView.userInteractionEnabled=YES;
    [self.view addSubview:playerView];
    
}
-(void)songEnded:(NSNotification *)notification{
//    NSLog(@"---%@",notification.object);
//    NSLog(@"--%d",n);
//    NSLog(@"-----------------------%d",littletag);
    if (Flag == YES) {
        n = littletag;
        Flag = NO;
    }
    //Add a mask animation realization
    [UIView beginAnimations:@"Curl"context:nil];//The animation begins to
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [(UIButton *)[self.view viewWithTag:n+1+1000] setAlpha:1];//Is the video below hungry thumbnail display with the video display
    [(UIButton *)[self.view viewWithTag:n+1000] setAlpha:0.2];
    [UIView commitAnimations];
    
    n++;
    //When n=34, when finally a playback, the re initialization.
    if (n==34) {
        n=0;
        [(UIButton *)[self.view viewWithTag:n+1000] setAlpha:1];
        [self initPlayer];
         [scoll setContentOffset:CGPointMake(0,scoll.contentOffset.y) animated:YES];
    }
    if(n>=10&&n<27){
        [scoll setContentOffset:CGPointMake(scoll.contentOffset.x+90,scoll.contentOffset.y) animated:YES];
    }
    
}

//Return to other pages, to cancel all notifications

//When returning the remove all notifications

- (void)releaseQueuePlayer

{

n=0;

for (int songPointer = 0; songPointer <[arryItems count]; songPointer++) {

[[NSNotificationCenter defaultCenter] removeObserver:self

name:AVPlayerItemDidPlayToEndTimeNotification

object:[arryItems objectAtIndex:songPointer]];

}

[queuePlayer removeAllItems];

[arryItems removeAllObjects];

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"startMovie" object:nil];

[queuePlayer pause];   

}

,,Click a thumbnail, playing a video, and then followed by the following continue to play

//To return to the page to play method

-(void)replayMovie:(NSNotification *)tag

{

//

NSLog(@"----%@",tag.object);

[queuePlayer removeAllItems];

//

NSLog(@"***************%d",[tag.object intValue]);

littletag=[tag.object intValue];

for (int i = littletag; i <arryItems.count; i++) {

AVPlayerItem* obj = [arryItems objectAtIndex:i];

if ([queuePlayer canInsertItem:obj afterItem:nil]) {

[obj seekToTime:kCMTimeZero];

[queuePlayer insertItem:obj afterItem:nil];

}

}

for (int i=0; i<34; i++) {

[(UIButton *)[self.view viewWithTag:1000+i]setAlpha:0.2];

}

[(UIButton *)[self.view viewWithTag:littletag+1000]setAlpha:1];

[queuePlayer play];

//

if(littletag>=10){

//

[scoll setContentOffset:CGPointMake(scoll.contentOffset.x+90,scoll.contentOffset.y) animated:YES];

//

}

}

It is learned, hope to be able to pay attention, remember




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Cash at November 21, 2013 - 10:37 PM