nfarina / calloutview

A lightweight callout view class for iOS mimicking UICalloutView.
http://nfarina.com/post/78014139253/smcalloutview-for-ios-7
Apache License 2.0
1.2k stars 189 forks source link

SMCalloutView is placed at end of cgrect.width instead of centered in iOS 8 #67

Open DrBeak1 opened 10 years ago

DrBeak1 commented 10 years ago

I found that I needed to update a project using SMCalloutView because the callouts point was pointing at the far right edge of the specified rect instead of in it's horizontal center. I fixed this in my code by using calloutOffset = CGPoint(-view.frame.size.width/2, 0.0);

Also, thanks for easy to use class :)

nfarina commented 10 years ago

Glad that fixed your problem - I'm not seeing it myself in the sample project though, can you explain more how to reproduce?

DrBeak1 commented 10 years ago

Sorry for not explaining better - Perhaps it had to do with my setup. I was showing the callout from a UIToolbar like so:

-(void)displayCallout
{ 
    UIView *editButton = (UIView *)[self.keyboardToolbar.subviews lastObject];
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){
        CGPoint offset = CGPointMake(-editButton.frame.size.width/2, 0.0);
        [self.callout setCalloutOffset:offset];
    }
    [self.callout presentCalloutFromRect:editButton.frame
                                  inView:self.keyboardToolbar
                       constrainedToView:self.view
                                animated:YES];    
}

You'll notice that in the above I included what I did to fix the offset in iOS 8.