Simple use of notifications

Source: Internet
Author: User
// Send a notification
Nsnotification * updatenotifi = [nsnotification notificationwithname: icationication_name_update_push object: Nil];
[[Nsicationcenter center defacenter center] postnotification: updatenotifi]; [nsicationicationcenter defacenter center] addobserver: Self selector: @ selector (addfavwork) Name: @ "add_stylist_work" Object: Nil];-(void) addfavwork {
// Add to Favorites If no favorites is available
Appstatus * As = [appstatus sharedinstance];
If ([as. User hasaddfavwork: Self. Work. ID]) {
Self. collectimage. Image = hasaddwork;
} Else {
Isoperatework = yes;
[[Userstore sharedstore] addfavwork: ^ (nserror * ERR ){
If (ERR = nil ){
[[Stylistworkstore sharedstore] getstylistworklist: ^ (page * Page, nserror * ERR ){
Isoperatework = no;
[Svprogresshud showsuccesswithstatus: @ "added to favorites! "Duration: 1.0];
Self. collectimage. Image = hasaddwork;
Self. numofcollect. Text = [nsstring stringwithformat: @ "% d users have added this file to Favorites", ++ self. Work. collectedcount];
[[Nsicationcenter center defacenter center] postnotificationname: @ "operate_work" Object: Nil];
[Mobclick event: log_event_name_add_fav_work attributes: [nsdictionary dictionarywithobjectsandkeys: @ (self. Work. Stylist. ID), @ "", nil];
} URL: As. User. idstr Refresh: Yes];
} Else {
[Svprogresshud showerrorwithstatus: @ "failed to add to favorites. Please try again later! "Duration: 1.0];
Isoperatework = no;
}
} Userid: As. User. idstr workid: Self. Work. ID];
Nsdictionary * dict = [nsdictionary dictionarywithobjectsandkeys: @ (self. Work. ID), @ "work ID", nil];
[Mobclick event: log_event_name_add_fav_work attributes: dict];
}
}

-(Void) scrollviewdidscroll :( uiscrollview *) scrollview
{
[Self drivescrollview: scrollview lastoffsety: lastoffsety scrollviewheight: scrollviewheight topview: Self. header];
Lastoffsety = scrollview. contentoffset. Y;
}

-(Void) drivescrollview :( uiscrollview *) scrollview lastoffsety :( float) _ lastoffsety scrollviewheight :( float) _ scrollviewheight topview :( uiview *) view {
If (scrollview. contentoffset. y> 0 & scrollview. contentoffset. Y <(scrollview. contentsize. height-scrollview. frame. size. height) & scrollview. contentsize. height> (view. frame. size. height + _ scrollviewheight + general_margin )){
If (_ lastoffsety-scrollview. contentoffset. Y> 0 & _ lastoffsety <(scrollview. contentsize. Height-scrollview. Frame. Size. Height) {// drop-down
If (view. Frame. Origin. y! = 0 ){
[Uiview animatewithduration: 0.5 animations: ^ {
View. Frame = cgrectmake (0, 0, screen_width, view. Frame. Size. Height );
Scrollview. Frame = cgrectmake (0, view. Frame. Size. Height, screen_width, _ scrollviewheight );
}];
}
} Else if (_ lastoffsety-scrollview. contentoffset. Y <0) {// push up
If (view. Frame. Origin. y! =-View. Frame. Size. Height ){
[Uiview animatewithduration: 0.5 animations: ^ {
View. Frame = cgrectmake (0,-view. Frame. Size. Height-splite_line_height, screen_width, view. Frame. Size. Height );
Scrollview. Frame = cgrectmake (0, 0, screen_width, _ scrollviewheight + view. Frame. Size. Height );
}];
}
}
}
}

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.