:
Code:
-(void) viewdidload {[Super viewdidload]; Additional setup after loading the view, typically from a nib. Uiimageview *imageview=[[uiimageview Alloc]initwithframe:cgrectmake (50, 100, 200, 200)]; Imageview.backgroundcolor=[uicolor Redcolor]; [Self.view Addsubview:imageview]; [Self setimageurlwithactivityindicator:@ "I love you!": ImageView]; }//the network requests a picture, add the loading control-(void) Setimageurlwithactivityindicator: (nsstring*) urlstring:(Uiimageview *) image{if (![ URLString isequaltostring:@ ""]) {//__block uiactivityindicatorview *activityindicator = nil; Uiactivityindicatorview *activityindicator = nil; Activityindicator = [Uiactivityindicatorview.alloc initwithactivityindicatorstyle: Uiactivityindicatorviewstylegray]; [Image Addsubview:activityindicator]; Cgpoint point = Cgpointmake (IMAGE.FRAME.SIZE.WIDTH/2, IMAGE.FRAME.SIZE.HEIGHT/2); Activityindicator.center = point; [ActivityindIcator startanimating]; [Image Setimagewithurl:[nsurl Urlwithstring:[image_url stringbyappendingformat:@ "%@", URLString]] PlaceholderI Mage:nil success:^ (UIImage *image) {NSLog (@ "... success code here ..."); [Activityindicator stopanimating]; [Activityindicator Removefromsuperview]; } failure:^ (Nserror *error) {NSLog (@ "... failure code here ..."); [Activityindicator stopanimating]; [Activityindicator Removefromsuperview]; }]; }}
Web request picture