ios - Objective-C protocol in Swift - shows does not conform error -
The
I'm trying to use Objective-C library (MWPhotoBrowser) into Swift app I my Swift Class MWPhotoBrowser Decompose the protocol by implementing the necessary methods. However, I keep the following error:
"Type 'Photo Library' does not conform to protocol '' MWPhotoBrowserDelegate ''
Does the Cocoa Protocol work properly? This problem has been encountered
Here is the sample code:
Class PhotoLibrary: UIImageView, MWPhotoBrowserDelegate {init () {super.init (frame: CGRectZero)} Func NumberOfPhotosInphotoBrowser (photoBrowser: MWPhotoBrowser!) - & gt; Int {return 0} func photoBrowser (photoBrowser: MWPhotoBrowser !, photoAtIndex index: Int) - & gt; MWPhoto! {Return nil}}
Protocol Definition This way :
@protocol MWPhotoBrowserDelegate & lt; NSObject & gt; - (NSInteger) numberoffofotoInfo browser: (MWPhotoBrowser *) photoBrowser; - (id & lt; MWPhoto & gt;) Photobraser: (MWPhotoBrowser *) Fotobraujhr Fotoattindeks: (Ansaiantegr) index; @optional - (ID & lt; MWPhoto & gt;) Fotobrojhr: (MWPhotoBrowser *) Fotobrosr Thnbfotoatindeks: (Ansuintegr) index; - (MWCaptionView *) photoBrowser: (MWPhotoBrowser *) photoBrowser captions ViewForFhotoAtIndex: (NSUInteger) index; - (NSString *) Photobraser: (MWPhotoBrowser *) Photobrowser Title ForphotoAttengEx: (NSUntengar) Index; - (blank) Photobrassor: (MWPhotoBrowser *) Photobraser did the display photoAtindex: (NSUntengar) index; - (zero) Photobraser: (MWPhotoBrowser *) Photobrowser ActionbuttonpressFourFontAutEXx: (NSUIENTGAR) Index; - (BOOL) Photobraser: (MWPhotoBrowser *) PhotoBrowser is selected for imported data: (NSUntiger) Index; - (zero) Photoboother: (MWPhotoBrowser *) PhotoBrewer PhotoAntindex: (Indexed) Index selected changed: (BOOL) selected; - (zero) Photo BrowserDifffish Model Presentation: (MWPhotoBrowser *) photoBrowser; @end
I got to work on my swift application with the following code without MWPhotoBrowser MWPhotoBrowser Change the codebase
function showFullScreenImage (Image: UIImage). {The photo: MWPhoto = MWPhoto (: Pictures) self.photos = [Photo] to browser: MWPhotoBrowser = MWPhotoBrowser (Representative: own) browser.displayActionButton = true browser.displayNavArrows = false browser.displaySelectionButtons = false browser.zoomPhotosToFill = true browser .alwaysShowControls = false browser.enableGrid = false browser.startOnGrid = false browser.enableSwipeToDismiss = true self browser.setCurrentPhotoIndex (0). Navigation Controller? .UpviewController (Browser, Animated: True)} Function NumberOfphotoSfo Browser (Photo Sphere: MVP Photo Bros.!) - & gt; UInt {Returns UInt (self.photos.count)} func photoBrowser (Photo Broser: MWPhotoBrowser !, photoAtIndex Index: UInt) - & gt; MWPhotoProtocol! {If the index is Self.photos.count {returns as photos.objectAtIndex (Int (index))! MWPhoto} return to zero} function photoBrowserDidFinishModalPresentation (photoBrowser: MWPhotoBrowser) {self.dismissViewControllerAnimated (true, completion: zero)}
I set bridesmaid pictures as a class, such as That Personal Photos - [...]
, and the bridging of my app - the following import into the Header.h file:
#import & lt; MWPhotoBrowser / MWPhoto.h & gt; #import & lt; MWPhotoBrowser / MWPhotoBrowser.h & gt;
I found most of the code above.
Comments
Post a Comment