New IOS Assistant

Source: Internet
Author: User

September is coming soon. In order to prevent new students from getting lost, the good-hearted students are making assistants for new monks.



Here we mainly recommend IOS image insertion. There are many button buttons on one interface, each of which has its own unique functions, but a button alone will look ugly, at this time, you only need to make a button for an image and jump to the interface when the user clicks the image accidentally to implement the button function, which will look more beautiful.

For example, when you click the hospital landscape:


Will appear




And so on.

Edit the following code in rootview:

-(Void) setbutton {

Uiimage * II = [uiimage imagenamed: @ "resource/button2.png"];

Uibutton * button2 = [uibuttonbuttonwithtype: uibuttontypecustom];

[Button2setframe: cgrectmake (self. View. Frame. Size. width/2-125, self. View. Frame. Size. Height/2 + 9,250, 84)];

[Button2 setbackgroundimage: iiforstate: uicontrolstatenormal];

[Button2 addtarget: selfaction: @ selector (inforinforview2) forcontrolevents: uicontroleventtouchupinside];

[Self. View addsubview: button2];

}

-(Void) beginforview2 {

Self. thrid = [[viewcontroller alloc] init];

Thrid. Title = @ "courtyard view ";

[Self. navigationcontrollerpushviewcontroller: thrid animated: Yes];

}

Don't forget to add [self setbutton] In-(void) viewdidload;

This will jump to the next interface, and then add it in the-(void) viewdidload of this interface

Uibarbuttonitem * leftbutton = [[uibarbuttonitemalloc] initwithbarbuttonsystemitem: uibarbuttonsystemitemreply target: selfaction: @ selector (selectleftaction :)];

Self. navigationitem. leftbarbuttonitem = leftbutton;

Cgrect scrollviewrect = cgrectmake (0,-22, self. View. Frame. Size. Width, self. View. Frame. Size. height + 44 );

Nsinteger picnum = 9;

Self. myscrollview = [[uiscrollview alloc] initwithframe: scrollviewrect];

Self. myscrollview. pagingenabled = yes;

Self. myscrollview. contentsize = cgsizemake (scrollviewrect. Size. Width * picnum, scrollviewrect. Size. Height );

Myscrollview. pagingenabled = yes;

Myscrollview. showshorizontalscrollindicator = no;

Myscrollview. showsverticalscrollindicator = no;

[Self. View addsubview: Self. myscrollview];

Nsinteger I;

Uiimageview * imageview;

Cgrect imageviewrect = self. View. bounds;

For (I = 0; I <picnum; I ++ ){

Uiimage * PIC = [uiimage imagenamed: [nsstringstringwithformat: @ "picinschool/yndt0000d.png", I];

Imageview = [self newimageviewwithimage: picframe: imageviewrect];

[Self. myscrollviewaddsubview: imageview];

Imageviewrect. Origin. x + = imageviewrect. Size. width;

}

The image is displayed one by one. You can preview the image by swiping your finger to the right or left. However, the key is that the image must be in the correct position. The sequence numbers to be displayed must be correctly arranged one by one starting from 0.

 

When the senior student completes this project, he feels that iOS will do it. After using it, it will become very simple. At the time of learning, it is hard to understand because he just got in touch with it. However, as a technician, loneliness and endless exercise are essential. Only continuous exercises, code optimization, and self-improvement can keep up with the times, and will not be eliminated. In the course of doing this, I encountered many difficulties, but I absolutely cannot give up. I can only use my own strategy one by one, at last, you can understand the joy that your efforts can help others.

 

The computer is suffering from infinite possibilities!

~ Yushun

















Related Article

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.