[위 에] [IOS] 완전한 plist 읽 기 demo

여가 시간 에 쓴 plist 읽 기 demo 는 초보 자 에 게 적합 합 니 다. 부족 한 점 은 지적 해 주 십시오 (다운로드 주소 첨부)
//
//  PlistDemoView.m
//  PlistDemo
//
//  Created by     on 12-3-25.
//  Copyright (c) 2012  __MyCompanyName__. All rights reserved.
//

#import "PlistDemoView.h"

@implementation PlistDemoView
@synthesize imageDemo;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    NSString *imagePath= [[NSBundle mainBundle] pathForResource:@"images" ofType:@"plist"];
    NSDictionary *imageDiction= [NSDictionary dictionaryWithContentsOfFile:imagePath];
    for (int i=1; i<=imageDiction.count; i++) {
        NSDictionary *dataFromPlist=[NSDictionary dictionaryWithDictionary:[imageDiction objectForKey:[NSString stringWithFormat:@"image%d",i]
                                                                            ]];
        
        NSString *stringPlist=[dataFromPlist objectForKey:@"imageDetail"];
        NSLog(@"imagePlist%@",stringPlist);
        
        NSString *imageName=[dataFromPlist objectForKey:@"imageName"];
        int imageLeftTopL=[[dataFromPlist objectForKey:@"leftTopL"] intValue];
        int imageLeftTopR=[[dataFromPlist objectForKey:@"leftTopR"] intValue];
        int imageWidth=[[dataFromPlist objectForKey:@"width"] intValue];
        int imageHeight=[[dataFromPlist objectForKey:@"height"] intValue];
        
        imageDemo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
        [imageDemo setFrame:CGRectMake(imageLeftTopL, imageLeftTopR, imageWidth, imageHeight)];
        
        [self.view addSubview:imageDemo];
    }
    
    
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	return YES;
}

@end

demo 다운로드 주소:http://download.csdn.net/detail/dongge_111/4213235

좋은 웹페이지 즐겨찾기