[Original] fixed bug that existed on Dejalactivityview system before iOS8

Source: Internet
Author: User

Dejalactivityview is a foreign third-party library that customizes the text content and the text length of the daisy-load indicator effect. The third-party library, unlike other HUD, can cover the keyboard, customize the cover Navigationbar or do not obscure the Navigationbar, and display the activity view in the status bar. The library GitHub address: Https://github.com/Dejal/DejalActivityView

Dejalactivityview has a bug on a system prior to iOS 8 and today uses the latest version on GitHub with the same bug. I am now working on a smart home company in Shenzhen ZYYZN Development ipad version of the App,app in the loading prompt uses the third-party library. Development of the app is a horizontal version of the display, then the problem arises, Dejalactivityview on the iOS 7.1 system, when the app is flat, the Dejalactivityview prompt box can not follow the app interface consistent display as a horizontal screen, such as:

[Dejalbezelactivityview activityviewforview:[uiapplication Sharedapplication].keywindow withLabel:@ "is logged in, please later ..."] ;

What do I do when the effect is inconsistent with the effect I expected? Is it to replace it with another set of third-party libraries, such as Mbprogresshud, or is it patient to modify? Because my ipad version of the app is based on the iphone version of the revision, the iphone version is a vertical version, the ipad to be a horizontal version, if you replace a set of third-party cue library, too much work. Just be patient and change dejalactivityview.

In DEJALACTIVITYVIEW.M, the implementation of the @implementation Dejalbezelactivityview is found-(void) layoutsubviews, which is added at the end of the method

[Self addobserver]; [Self ondeviceorientationchange:nil];

Specific as follows:

-(void) layoutsubviews; {    //If we ' re animating a transform, don ' t lay out now, as can ' t use the Frame property when transforming:    If (! Cgaffinetransformisidentity (self.borderView.transform))        return;        Self.frame = [self enclosingframe];        ......     ......  This code is not posted, occupies the position    ...        Calculate the position of the label:horizontally centered and near the bottom of the border view:    cgrect Labelfram e = self.activityLabel.frame;    Labelframe.origin.x = Floor (0.5 * (borderframe.size.width-labelframe.size.width));    LABELFRAME.ORIGIN.Y = borderframe.size.height-labelframe.size.height-10.0;    Self.activityLabel.frame = Labelframe;        [Self addobserver];    [Self ondeviceorientationchange:nil];}

Implementation of the Addobserver method:

#pragma mark--#pragma mark--(1)-Address the third-party library on systems prior to iOS 8, the APP will not be able to follow the Bug,written by Sunminmin 1/30/2015//displayed sideways on the screen to accept notification of status bar changes Center Monitor status bar Change-(void) addobserver{    [[nsnotificationcenter defaultcenter] addobserver:self selector: @selector ( Ondeviceorientationchange:) name:uiapplicationdidchangestatusbarorientationnotification Object:nil];}

Ondeviceorientationchange Method Implementation:

Rotation view-(void) Ondeviceorientationchange: (ID) sender{    if ([[Uidevice Currentdevice] systemversion] According to the direction of the device being monitored . Floatvalue < 8.0) {        uiinterfaceorientation orientation = [[UIApplication sharedapplication] Statusbarorientation];        if (orientation = = Uiinterfaceorientationlandscapeleft) {            Self.activityIndicator.superview.transform = Cgaffinetransformmakerotation (-m_pi_2);        }        if (orientation = = uiinterfaceorientationlandscaperight) {            Self.activityIndicator.superview.transform = Cgaffinetransformmakerotation (m_pi_2);}}}    

@implementation the listener is registered in the Layoutsubviews method of the Dejalbezelactivityview, it is necessary to remove the listener in the Dealloc method:

Remove Listener in Dealloc-(void) dealloc{[self    removeobserver];} Remove the status bar Change Notification Center listener-(void) removeobserver{    [[Nsnotificationcenter Defaultcenter] removeobserver:self name: Uiapplicationdidchangestatusbarorientationnotification Object:nil];}

After making the above changes, it is normal for Dejalactivityview to display the prompts on iOS 7 devices, but not perfect enough. Because in the pop-up Dejalactivityview, the Dejalactivityview will be rotated 90 degrees before correctly displayed as a horizontal version, which affects the effect, is not the effect I need. Through the Dejalactivityview display process, I judge the problem appears in its animation effect, then I went to find its animation implementation method, Oh, found, is-(void) animateshow; At this point I need to modify in this method, the problem is on the system before iOS 8, First of all, we need to make the system version judgment, the second is to modify the animation effect.

-(void) animateshow; {    self.alpha = 0.0;    Self.borderView.transform = Cgaffinetransformmakescale (3.0, 3.0);    [UIView Beginanimations:nil Context:nil];//[uiview setanimationduration:5.0];            Uncomment to see the animation in slow motion    self.borderView.transform = cgaffinetransformidentity;    Self.alpha = 1.0;    [UIView commitanimations];}

In the Animateshow method above, add the following code, specifically implemented as:

-(void) animateshow; {    if ([[Uidevice Currentdevice] Systemversion].floatvalue >= 8.0) {        self.alpha = 0.0;        Self.borderView.transform = Cgaffinetransformmakescale (3.0, 3.0);                [UIView Beginanimations:nil Context:nil];        [UIView setanimationduration:5.0];            Uncomment to see the animation in slow motion                self.borderView.transform = cgaffinetransformidentity;        Self.alpha = 1.0;                [UIView commitanimations];    } else {#pragma mark--#pragma mark--(2)-Fix the third-party library on a system prior to iOS 8, the APP will not be able to follow the Bug,written by Sunminmin that is displayed horizontally on the screen 1/30/2015        Self.alpha = 0.0;        [UIView Beginanimations:nil Context:nil];        Self.alpha = 1.0;        [UIView commitanimations];}    }

So far, it has been modified, on the iOS 7 device to execute the following code again, the expected effect came out, such as:

[Dejalbezelactivityview activityviewforview:[uiapplication Sharedapplication].keywindow withLabel:@ "is logged in, please later ..."] ;

The modified Dejalactivityview library is: http://pan.baidu.com/s/1mgp8Aqk Baidu Network disk

[Original] fixed bug that existed on Dejalactivityview system before iOS8

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.