I am using Parse SDK 1.6.0. I used storyboard and dragged an UIImageView to a custom UITableViewCell. When I connect the UIImageView to the swift file, I changed the class to PFImageView. However, Xcode keeps telling me "Use of undeclared type 'PFImageView'".
I checked and I found the PFImageView.h is in the ParseUI.framework. I also discovered that I am not able to use other things included in ParseUI.framework like PFTableViewCell. But I am able to use the Parse.framework like PFUser, PFObject, PFFile etc.
Can anyone help me out? Many thanks.
I think you mean: #import <ParseUI/ParseUI.h>
This includes the ParseUI.framework which includes PFImageView
You will also need #import <Parse/Parse.h>
This includes the Parse.framework classes like PFUser, etc.
You just need to import the ParseUI on the class you are using, for example:
import ParseUI
You can then, on your Storyboard, select a normal ImageView, go to the Identity Inspector on your interface builder, change its class from UIImageView to PFImageView
Connect it as an outlet as normal to your code, but instead of connecting as a UIImageView ensure it is a PFImageView, like this:
#IBOutlet weak var imgTestImage :PFImageView!
You now have access to the PFImageView attributes such as:
let theImage = yourObject.valueForKey("profileImage") as? PFFile
imgTestImage.file = theImage
imgTestImage.loadInBackground()
Hope this helps
I found the answer.
It worked after I added this line in the bridge file.
#import <Parse/Parse.h>
Related
I may be in compiler hell right here.
I'm implementing a Snapshot test in Swift, calling a property on an Objective-C VC, but that property is a class, written in Swift, bridged in.
In MyViewController.h:
#class TextEntryView;
#interface MyViewController: AbstractTextEntryViewController
#property (nonatomic, strong) TextEntryView *textEntryView;
#end
In TextEntryView.swift:
#objc(TextEntryView) class TextEntryView: UIView
And in my test, I'm trying to call
vc.textEntryView where vc is of type MyViewController and I'm getting the error:
value of type MyViewController has no member textEntryView
My bridging headers look good. If I add an NSString property to the .h file above, I'm able to reference it in the test. Also, when I command-click on MyViewController in my test, it takes me to the .h file rather than the .swift generated version of that file (which seems like a symptom of this problem).
I may be pushing Xcode 8 beyond its limits.
You need to make sure you import your app at the top of the source file for your test. For example, if your app is called MyApp, insert at the top of the test file:
import MyApp
If I leave out the import, I get the same behavior you are seeing. Additionally, as long as the import is there, you shouldn't have to bother with bridging headers for the unit test.
Have you tried to import to Test Target ?
Since you already imported the Xcode-generated header file for your Swift code into Objective-C .m file.
Please also remove #objc annotation from TextEntryView class since it's a subclass of UIView thus accessible and usable in Objective-C. keeping the annotation #objc may cause a side effect.
To be accessible and usable in Objective-C, a Swift class must be a
descendant of an Objective-C class or it must be marked #objc.
a simple case of "side-effect" is when a (swift) UIViewController subclass is marked #objc and used as custom subclass in storyBoard:
instantiateViewControllerWithIdentifier will instantiate a UViewController instead of the subclass we set in the storyBoard.
with error Unknown class _TtC10AbcdViewController in Interface Builder file
I am working on a project which somewhere needs to send the edited image to another ViewControler using segue or storyboard.
Some points to understand first.
The ViewController i am sending image which is configured using Objective C.
And the image is to be pass that ViewController which is configured using Swift Lang.
Problem:
The Swift Class which is imported in Objective .m file is not visible so it lets me to create its object to make reference of its members.
I tried:
// here i am not able to create SwiftVC class object so i can pass image further
SwfitVC *object = [self.storyboard instantiateViewControllerWithIdentifier:#"VC_Identifire"];
object.image = image;
[self.navigationController pushViewController:object animated:YES];
SwftVC Class is not visible after importing to .m file.
Please have look. Thanks.
In order to make your Swift file visible; in your .m file you'll have to write this import statement.
#import "YourProjectName-Swift.h"
Clean and build then you'll be able to use your Swift class.
Alternate way:
You can save the image to Document Directory in Objective-c class and fetch it into Swift Class.
Might be a help this logic.
I tried to find the solution, but I couldn't find anyone with the same problem.
I'm using Xcode 8.2.1, writing in Objective-C.
I'm actually having a problem with adding a UIImageView to IBOutletCollection. I'm trying to do it using the Interface Builder.
dragging to connect ImageView with the Collection
I've already deleted any existing outlets of that ImageView.
I'm also adding screenshot of the header file of the MasterViewController - I guess everything is OK here.
declaration of the collection
Thanks for help.
You have to use IBOutletCollection(UIImageView) instead of IBOutletCollection(UIViewController)
I wrote some code in Swift for an iOS app in XCode (7.1.1) and I can't use the drag and drop in the interface builder for the outlet I want to connect. I tried to do it manually too but the outlet didn't show up in the reference collection when I tried to do it.
I did see this answer:
Can't connect IBOutlet in Interface Builder
But this appears to be for Objective-C/older versions of XCode. The way I have it right now is I have my main DataViewController.swift file and then I created a PhotoViewer.swift file (it's just an example so the code doesn't really matter it's pretty simple). I used the following code:
import Foundation
import UIKit
class PhotoViewer: UIViewController {
#IBOutlet weak var viewerButton: UIButton!
func loadPhotoUI() {
viewerButton.setTitle("View Photos", forState: .Normal)
}
}
The viewerButton does not show up as an option and when I open up the story board and try to Ctrl-Click and drag to the file on the right side, it doesn't let me drop it in.
If I try it on the DataViewController.swift file (the one that was there when I started the initial template), it still works.
I'm guessing I just need to change a setting on the new file but I can't seem to figure that out. I basically will be using the classes functions in the DataViewController like:
let photoClass = PhotoViewer()
self.photoClass.loadPhotoUI()
etc etc. I'm just wanting to keep everything super organized.
I'm obviously a bit of a noob at Swift so thanks for the help!
Your ViewController in your Storyboard needs to be linked to your Swift file.
You have to change the Class to "PhotoViewer" in your Identify Inspector in your Storyboard Viewcontroller:
Scrolling of my tableview is very poor. So i want to use EGOImageView. Any tutorial or any suggestion.?
there are several way to load image smoothly. EGOImageView is one of them . first of use EGOImageView instead of UIImageView and in Nib(Xib) file drag imageview and set Class EGOImageView in identity section (Property toolbar ).
Second easiest way to load image in url Using AFNetworking class.
download This framework AFNetworking and only import
#import "UIImageView+AFNetworking.h"
and set image url like this
[cell.imgUser setImageWithURL:[NSURL URLWithString:data.strprofileimage]];
i think this is helpful to you. thanks