Query and sort in the SQLite of iOS to access the photo album of mobile phone albums

Source: Internet
Author: User

Day05

SQLite Query and sort in

Sort by query result: [[email Protected][nssortdescriptor sortdescriptorwithkey:@ "age" ascending:yes]];

Set query criteria:

Nspredicate *pre=nil;

1. comparison operators > < >= <= = = = =

pre=[nspridicate [email protected]"age>40"];

2. range operator in between

Pre=[[email protected]"Age between{30,40}";

pre=[nspredicatepredicatewithfromat:@ "name in{' aaaaa ',' BCD '}"];

3. string processing beginswith endwith Contans C: case-insensitive D: pronunciation -insensitive

Pre=[[email protected]"name BEGINSEITH[CD] ' a '"];

Pre=[[email protected]"name CONTAINS[CD]" ' a '];

4. wildcard characters like? Represents a single character * represents more than one character

Pre=[[email protected]"name LIKR[CD] ' *m '"];

Finally, don't forget to add [Requestsetpredicate:pre];

Get photos from your albums:

Step1 : Creating an instance of Uiimagepickercontroller

Uiimagepickercontroller*pic=[[uiimagepickercontroller Alloc]init];

Step2: abide by the agreement and set yourself up as an agent

<uinavigationcontrollerdelegate ,uiimagepickercontrollerdelegate>

pic.delegate=self ;

Step3 : Call method

[Picsetsourcetype:uiimagepickercontrollersourcetypesavephotosalbum] ;

uiimagepickercontrollersourcetypephotolibrary,// Direct access to library

uiimagepickercontrollersourcetypecamera,// turn on the camera

uiimagepickercontrollersourcetypesavedphotosalbum// Direct access to albums Photosalbum albums

Step4: Call the method that launches the new view present introduced because there is a Navigationcontroller agent in the Protocol

[Selfpresentviewcontroller: Pic Animated:YEScompletion:nil]

Step5: implemented in the following method

- (void) Imagepickercontroller: (Uiimagepickercontroller *) Pickerdidfinishpicingmedia Withinfo: (nsdicationary *) info;

Create an instance of UIImage get all the photos in the following ways

Uiimage*image=[info Objectforkeyedsubscript:uiimagepickercontrolleroriginalimage];

ScrollView Settings that are commonly used in

does not appear white area: bounces=no;

Showhorizontalscrollindicator=no; Set horizontal without scrolling horizontal level

Showverticalscollindicator=no; Set vertical without scrolling vertical vertical

How to implement delete photos in ScrollView change the location of other photos in ScrollView

can traverse to get all the photos in the ScrollView general use ImageView

to implement the position of changing coordinates in a loop

STEP6 : In the method can be based on some of the properties of Navigationcontroller to get the interface which is jumping

-(void) Navigationcontroller: (uinavigationcontroller*) Navigationcontroller Willshowviewcontroller: ( uiviewcontroller*) Viewcontroller animated: (BOOL) animated{}

Navigationcontroller.viewcontroller.count=1: which interface to jump to?

How to save photos to a photo album in your phone's memory

Step1 : Get a saved photo

A. Create a canvas

Uigraphicsbeginimagecontext (ImageView.frame.size)

B. render the ImageView background to the canvas

[ImageView.layrranderInContext:UIGraphicsCurrentContest()];

c. Take the pictures out of the canvas

Uiimage*image=uigraphicsgetimagefromcurrentimagecontext ();

d. End Rendering

Uigraphicsendimagecontext ();

Step2 : Save the photo to the system album Selector do not write blindly click to method the internal system has been written for you.

uiimagewritetosavephotosalbum (Image, Self, @selector (image:didFinishSavingWithError:contextInfo :), nil);

Implementation Method

-(void) Image: (UIImage *) image didfinishsavingwitherror: (Nserror *) Errorcontextinfo: (void *) contextinfo{

uialertview *alertview =[[uialertviewalloc]initwithtitle:@ " Prompt" message:@ "Picture Save Complete" delegate: selfcancelbuttontitle:@ "OK" otherbuttontitles:nil, nil];

[Alertview show];

}

How to implement inserting a background in a view

Step1 : First create an instance of ImageView to a picture

Step2 :

method One:

[Self.view insertsubview:imageviewatindex:0] Insert to the lowest level of the view

method Two:

[Self.view Addsubview:imageview]; Add to view ImageView will overwrite the original view

Bring a child view to the front display

[Self.viewbringSubViewToFront:imageView];

Determine if the clicked position is on a view

Method One: Determine whether the position of the click is in the frame of the view

if (Cgrectcontainspoint (self.imageview.frame,p));

Method Two: Determine if the frame of the two views has a coupling

if (Cgrectcontainsrect (imageview.frame,imageview.frame))

Reposition view when view position changes

Method One: Change the original frame

CGRect Oldfram =imageview.frame;

CGRect newfram=[( the view to convert) Convertrect:oldframe ToView:self.view];

Method Two: Change the original center point coordinates

Cgpoint Oldcenter=self.imageview.center

Cgpoint Newcenter=[self.viewconverpoint:oldcenter ToView:self.enitView];

Query and sort in the SQLite of iOS to access the photo album of mobile phone albums

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.