I don't know how to implement expandable and collapse tableview in SWIFT. I searched, but nothing in swift. Kindly guide me. How to do that?
My required output
This looks like a framework like CollapseClick.
It's a framework written in Objective-C.
But you can easily implement it in your Swift-Project. Just copy the .h and .m into your project and link it in your Bridging-Header.h file:
#import "CollapseClick.h"
#import "CollapseClickCell.h"
#import "CollapseClickArrow.h"
Related
I am trying to figure out how to detect the datapoint touched within a ORKLineGraphChartView so that I can take action on the datapoint selected, for example, more data for a date datapoint. I implemented the protocol ORKGraphChartViewDelegate, but can not find any functions on the delegate that return a touchpoint/datapoint for the chart. I can add a tap gesture to the chart view to get the X/Y of the touchpoint, but then I'm not quite sure how to get the datapoint for that location within the chart. Any help is appreciated.
For this, what I ended up doing was digging through the Objective-C classes and found a function that did exactly what I needed, but it hadn't been implemented in swift yet. So I created a bridging header in my application:
Bridging Header import:
#import "ORKLineGraphChartView+ORKLineGraphChartView_PointIndex.h"
And then I created another file which I used to expose the Objective-C function on the class ORKLineGraphChartView:
#import <ResearchKit/ResearchKit.h>
#interface ORKLineGraphChartView (ORKLineGraphChartView_PointIndex)
- (NSInteger)pointIndexForXPosition:(CGFloat)xPosition plotIndex:(NSInteger)plotIndex;
#end
This worked perfectly until hopefully swift contains all the functions from research kit. Hope this helps someone.
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>
I have this code a Custom class which extends UIImageView in Objective-C.
When I add to the project and add import to bridging header file my swift class can see
and use the code as usual but when i try to compile it.
I always get this error
I don't know why it is only happen to my CarBigImageView, I try to change the name of the file , create new file with new name and copy all the code there but none seem to work.
but other custom view such as Marker seem to be fine?
UPDATE : ADD MORE INFORMATION
here is my bridging header
#import <AFNetworking/AFNetworking.h>
#import <AFNetworking/UIImageView+AFNetworking.h>
#import <GSKeychain.h>
#import <JSONKit.h>
#import "CarBigImageView.h"
#import "sqlite3.h"
#import <time.h>
#import "Bridge.h"
#import "Marker.h"
here is my "CarBigImageView.h"
#import <UIKit/UIKit.h>
#protocol CarBigImageViewDelegate <NSObject>
- (void)didTouchColor:(UIColor*)coloc atPosition:(CGPoint)point;
#end
#interface CarBigImageView : UIImageView
#property (weak, nonatomic) id<CarBigImageViewDelegate> delegate;
#end
and here what it looks in the editor
and the result when compile
How can i solve this?
Make sure you left Xcode know where to find that file: in build settings look for "Objective-C Bridging Header". The value for that field should be something similar to "$(SRCROOT)/path/to/your/Bridging-Header.h" If you fill this out and hit enter, it SRCROOT will expand, and you can check if that full path is correct path.
When I want to transition from one view controller to another, I import the second view controller's header file into my first view controller's header file, by writing #import "SecondViewController.h". However, since I already defined UIColor category in my first view controller, when I try to import the second view controller, I enter the following error: Duplicate interface definition class for SecondViewController.
Here's my FirstViewController.h:
#import
#import "SecondViewController.h"
#interface FirstViewController : UIViewController
#end
#interface UIColor (ColorWithInt)
+ (UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha;
#end
I didn't meet any such errors so far when I develop this app, so it's definitely this category that is causing the issue here. So is it feasible to use category when I want to import another view controller class? Or are there any alternative ways to extend UIColor? I just want to define a function that takes RGB as 0 ~ 255 integer, not 0 ~ 1 floating values that UIColor uses on default.
I use iOS 7 and Xcode 5.
You might #import "SecondViewController.h" twice, just check FirstViewController.h/m file if both did that.
I have a feeling you're using this
#interface
instead of
#implementation
in your .m file.
Self Answer
I found out that the issue is not related to either FirstViewController or SecondViewController - let alone the category; it's because I imported almost all class' header file in AppDelegate.h in order to initialize the relationship among UITabBarController, UINavitationController, RootViewController, and Core Data and its lots of required properties. I didn't know that when I import a class in AppDelegate.h I cannot import the class at some other class's header file. Delete #import "FirstViewController.h"; and #import "SecondViewController.h;" in AppDelegate.h and I find my app being build properly now. Thanks to those who left comments in this post.
i'm working on a static library, where i need to have access to self.view
i'm trying to give the caller a reference to self.view by letting him pass it as a parameter
in the header file the .h
- (void) myM:(UIView *)myView;
but this is giving me an error:
expected a type
please can anyone help,
Thank you
Looks like you just need to import the UIKit headers. Add this at the top of your header file:
#import <UIKit/UIKit.h>
Just add a forward declaration to your header:
#class UIView;
if you need to use the view, add this to your .m file:
#import <UIKit/UIKit.h>