Key Contents of the lol box and contents of the lol box
// AFN function-imageview: load the network image and obtain the image. After obtaining the image, store it on the mobile phone.[Image setImageWithURLRequest: [NSURLRequestrequestWithURL: [NSURLURLWithString: [NSStringstringWithFormat: @ "% @", skin. bigImg] placeholderImage: nilsuccess: ^ (NSURLRequest * request, NSHTTPURLResponse * response, UIImage * image) {signature (image, self, @ selector (image: Signature: contextInfo :), nil);-(void) image :( UIImage *) image didFinishSavingWithError :( NSError *) error contextInfo :( void *) contextInfo
{
If (error ){
[SelfshowToastWithText: @ "Save not allowed"];
} Else {
[SelfshowToastWithText: @ "saved successfully"];
}}
_ Player = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: file] error: nil];
// NSLog (@ "% @", [NSURL fileURLWithPath: file]);
// [_ Player play];
// Audioplayer third-party class library playback File
AudioPlayer * player = [AudioPlayersharePlayer]; [player playWithDataSourceType: DataSourceTypeLocalwithURLString: file];
// Download an object
NSString * string = [NSStringstringWithFormat: HERO_SOUND_DESC_URL, pathName, fileName];
NSURL * url = [NSURLURLWithString: [stringstringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURLRequest * request = [NSURLRequestrequestWithURL: url];
AFHTTPRequestOperation * operation = [[AFHTTPRequestOperationalloc] initWithRequest: request];
Operation. inputStream = [NSInputStreaminputStreamWithURL: url];
Operation. outputStream = [NSOutputStreamoutputStreamToFileAtPath: fileappend: NO];
[Operation setCompletionBlockWithSuccess: ^ (AFHTTPRequestOperation * operation, id responseObject ){
NSLog (@ "Download successful ");
[_ TableviewreloadData];
} Failure: ^ (AFHTTPRequestOperation * operation, NSError * error ){
NSLog (@ "Download failed ");
}]; [Operation start];// Scale the scrollview to one time when the slide is stopped-(Void) scrollViewDidEndDecelerating :( UIScrollView *) scrollView
{_ PageIndex = scrollView. contentOffset. x/SCREEN_WIDTH;
For (UIScrollView * scrollview in scrollView. subviews)
{
If ([scrollview isKindOfClass: [UIScrollViewclass]) {[scrollview setZoomScale: 1.0];}
}
HeroSkin * skin = [_ heroskinobjectAtIndex: _ pageIndex];
_ Namelabel. text = skin. name;
_ Pricelabel. text = skin. price;
_ Pagelabel. text = [NSStringstringWithFormat: @ "% ld of % lu", _ pageIndex + 1, (unsignedlong) _ heroskin. count];
NSLog (@ "% ld", (long) _ pageIndex );}
// Shake the image
-(Void) ImageShake
{
CABasicAnimation * basic = [CABasicAnimationanimationWithKeyPath: @ "transform. rotation. z"];
Basic. fromValue = [NSNumbernumberWithFloat:-M_PI/16];
Basic. toValue = [NSNumbernumberWithFloat: M_PI/16];
Basic. duration= 0.1;
Basic. repeatCount = 3; [imageview. layeraddAnimation: basic forKey: @ "animateLayer"]; // AudioServicesPlaySystemSound (kSystemSoundID_Vibrate );}
// Detect motion
-(Void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event
{
If (motion = UIEventSubtypeMotionShake ){
[SelfImageShake];
[Playerplay];
}}
// Calculate the frame size of a string
-(CGSize) getStringRect :( NSString *) str
{
If (str. length <1 ){
ReturnCGSizeMake (0, 0 );
}
CGSize size;
NSAttributedString * string = [[NSAttributedStringalloc] initWithString: str];
// NSDictionary * attribute =@{ NSFontAttributeName: @ 12 };
Size = [string boundingRectWithSize: CGSizeMake (280,500) options: NSStringDrawingTruncatesLastVisibleLine |
NSStringDrawingUsesLineFragmentOrigin |
NSStringDrawingUsesFontLeadingcontext: nil]. size;
Return size ;}
-(CGFloat) caculateLabelHeightWith :( float) fontsize String :( NSString *) str
{
UIFont * font = [UIFontsystemFontOfSize: fontsize];
CGSize size = CGSizeMake (300,700 );
CGSize descriptionSize = [str sizeWithFont: font constrainedToSize: size lineBreakMode: NSLineBreakByWordWrapping];
Return descriptionSize. height ;}