Uiimageview loads network images, and nsoperationqueue asynchronously loads Images

Source: Internet
Author: User
# Import "newdetailviewcontroller. H "# import" Common. H "# import" newobject. H "# import" netrequest. H "# import <uikit/uikitdefines. h> @ interface newdetailviewcontroller () <response> {uilabel * response; uitextview * gwdetailcontenttext; uiimageview * imageview; nsurl * URL; uiview * opaqueview; optional * activityindicator ;} @ end @ implementation newdet Ailviewcontroller-(ID) initwithnibname :( nsstring *) nibnameornil bundle :( nsbundle *) handle {self = [Super initwithnibname: nibnameornil Bundle: nibbundleornil]; If (Self) {If ([[[uidevice currentdevice] systemversion] floatvalue]> = 7) {self. view. bounds = cgrectmake (0,-20, self. view. frame. size. width, self. view. frame. size. height) ;}} return self;}-(void) viewdidload {[uiapplication shared Application]. statusbarhidden = yes; [Super viewdidload]; // [self initview];}-(void) initview {uibutton * loginbutton = [[uibutton alloc] handle: cgrectmake (screen_width-40, 0, 40, 30)]; [loginbutton settitle: @ "return" forstate: uicontrolstatenormal]; loginbutton. titlelabel. textcolor = [uicolor blackcolor]; [loginbutton addtarget: Self action: @ selector (backtofather) forcontrolevents: uicontroleventtou Chupinside]; [self. view addsubview: loginbutton]; gwdetailtitletext = [[uilabel alloc] initwithframe: cgrectmake (10, 30, screen_width-20, 40)]; gwdetailtitletext. textalignment = nstextalignmentcenter; gwdetailtitletext. numberoflines = 0; gwdetailtitletext. linebreakmode = uilinebreakmodecharacterwrap; [self. view addsubview: gwdetailtitletext]; gwdetailtitletext1 = [[uilabel alloc] initwithframe: cgrect Make (10, 70, screen_width-20, 20)]; gwdetailtitletext1.textalignment = nstextalignmentleft; [self. view addsubview: gwdetailtitletext1]; web = [[uiwebview alloc] initwithframe: cgrectmake (10,100, screen_width-20, self. view. bounds. origin. Y + self. view. bounds. size. height-110)]; web. scalespagetofit = yes; web. delegate = self; [[web layer] setcornerradius: 10]; [web setclipstobounds: Yes]; web. scales Pagetofit = no; For (ID subview in web. subviews) {If ([[subview class] issubclassofclass: [uiscrollview class]) {(uiscrollview *) subview ). bounces = No ;}} web. backgroundcolor = [uicolor whitecolor]; [self. view addsubview: Web]; // gwdetailcontenttext = [[uitextview alloc] initwithframe: cgrectmake (10,100, screen_width-20, self. view. bounds. origin. Y + self. view. bounds. size. height-110)]; // GWD Etailcontenttext. layer. borderwidth = 1; // gwdetailcontenttext. editable = no; // [self. view addsubview: gwdetailcontenttext];}-(void) setchoiceddate :( newobject *) myarray {[self initview]; mylog (@ "% @", myarray ); // mylog (@ "% @", myarray [0]); // [@ "rel_title"] gwdetailtitletext. TEXT = myarray. rel_title; nsstring * Date = [[nsstring alloc] initwithstring: myarray. rel_date]; Date = [date substringtoindex: 10]; n Sstring * mystring = [nsstring stringwithformat: @ "publisher: % @ Date: % @", myarray. rel_user, date]; gwdetailtitletext1.text = mystring; mylog (@ "% @", myarray. rel_picpath); If (! [Myarray. rel_picpath isequaltostring: @ "null"]) {url = [nsurl urlwithstring: [nsstring stringwithformat: @ "% @", @ "http://www.xf0573.com", myarray. rel_picpath]; imageview = [[uiimageview alloc] initwithframe: cgrectmake (80, 0,160,120)]; imageview. layer. maskstobounds = yes; imageview. layer. cornerradius = 5.0f; [imageview setbackgroundcolor: [uicolor graycolor]; imageview. image = [uiimage imagenamed: @ "moren.png"]; [web addsubview: imageview]; opaqueview = [[uiview alloc] initwithframe: cgrectmake (0, 0,160,120)]; activityindicator = [[financialloc] initwithframe: cgrectmake (0, 0,160,120)]; [opaqueview setbackgroundcolor: [uicolor blackcolor]; [opaqueview setalpha: 0.6]; [imageview addsubview: opaqueview]; [opaqueview addsubview: activityindicator]; [activityindicator startanimating]; opaqueview. hidden = no; web1 = [[uiwebview alloc] initwithframe: cgrectmake (10,120, screen_width-20, self. view. bounds. origin. Y + self. view. bounds. size. height-web. frame. origin. y-130)]; web1.scalespagetofit = yes; web1.delegate = self; [web1 layer] setcornerradius: 10]; [web1 setclipstobounds: Yes]; web1.scalespagetofit = no; for (ID subview in web1.subviews) {If ([[subview class] issubclassofclass: [uiscrollview class]) {(uiscrollview *) subview ). bounces = No ;}} web1.backgroundcolor = [uicolor whitecolor]; [web1 loadhtmlstring: myarray. rel_content baseurl: Nil]; [web addsubview: web1]; nsoperationqueue * operationqueue = [[descrialloc] init]; nsinvocationoperation * op = [[nsinvocationoperation alloc] handler: Self selector: @ selector (downloadimage) object: Nil]; [operationqueue addoperation: op]; // [web loadrequest: req];} else if ([myarray. rel_picpath isw.tostring: @ "null"]) {[web loadhtmlstring: myarray. rel_content baseurl: Nil]; // gwdetailcontenttext. TEXT = myarray. rel_content ;}}- (void) downloadimage {uiimage * image = [uiimage imagewithdata: [nsdata datawithcontentsofurl: url]; imageview. image = image; [activityindicator stopanimating]; opaqueview. hidden = yes;}-(void) backtofather {[self dismissmodalviewcontrolleranimated: Yes];} @ end

Uiimageview loads network images, and nsoperationqueue asynchronously loads Images

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.