SO, I have a property to a UICollectionView Object
#property (strong, nonatomic) IBOutlet UICollectionView *collectionViewVARIABLE;
I held control and dragged the mouse, it's all linked up.
my problem is that it doesn't seem to actually work.
I try calling
[self.collectionViewVARIABLE registerClass:[MFH_mainfeed_CondensedViewCell class] forCellWithReuseIdentifier:#"MainIpadFeedCell"];
I get this error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier MainIpadFeedCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
If I put this call within cellForItemAtIndexPath using collectionView instead of the variable, it works.
I've tried the following on a button click, also nothing.
self.collectionViewVARIABLE.backgroundColor = [UIColor blackColor];
I have been at this for three days. My head hurts. Can somebody please tell me what I am missing.
Related
I'm building an experimentation app using the HMSegmentedControl framework. On this app I'm trying to add a UICollection view into a view made on a xib file, but I'm having trouble with it. The app crashes and I get this:
2016-02-01 10:23:40.693 SegmentControlExperimentation[1328:49671] *** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UICollectionView.m:3690
2016-02-01 10:23:40.699 SegmentControlExperimentation[1328:49671] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier MyCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
I've been looking it up everywhere, but I couldn't come with a solution.
So I made a github repo and I cloned my code on this link: https://github.com/nascimentorafael/SegmentControlExperimentation
It is a really small and simple code. If one runs it, will get this crash. So have a look on the ViewController class and the view.xib.
I hope someone can help me with this.
I browsed your github repository and found you didn't practice UICollectionView in a right way. However, if you would like to avoid the crash only, just comment out codes line 102-105 & line 128 in your ViewController.m
If you would like to put have your collectionView in view.xib, you need to insert this line in view.h
#property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
Refers above outlet in view.xib and comment out line 35-37 in ViewController.m
And then add the following codes for View *view in - (void)viewDidLoad {}
UINib *cellNib = [UINib nibWithNibName:#"CustomCollectionViewCell" bundle:nil];
[view.collectionView registerNib:cellNib forCellWithReuseIdentifier:#"MyCell"];
view.collectionView.delegate = self;
view.collectionView.dataSource = self;
Still please understand that the above recommendations are minimum changes for your current repository and may not be the best practice. There are many things need to be put into consideration and the combination will be very different according to each scenario.
I am using htautomcomplete to add autocompletion to a textfield and getting the error below.
As far as I know I have made the field in question an HTautomplete field but it is saying that it is trying to send the message to an UITextField. Could this be error or what else could cause this? Thanks for any ideas.
[UITextField setAutocompleteType:]: unrecognized selector sent to instance 0x17eea9a0
(lldb)
//code creating property
#property (unsafe_unretained, nonatomic) IBOutlet HTAutocompleteTextField *titleField;
Since this is an IBOutlet, it's most likely that you didn't set the class of your UITextField in the .xib file to be an HTAutocompleteTextField.
You can do so by selecting the object in your .xib file, then going to the Identity Inspector and setting the class under Custom Class.
I have created a Custom View Controller with XIB file.
In XIB file, I put a tableview and a slider to the view and connect all of them as IBOutlet to the File's Owner.
I check the File's owner class and it is my custom class, so it's ok.
I double checked the view and slider are connected with File's Owner.
But when I try to load my custom viewcontroller, I got this error:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NoteController 0x6bd1da0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _slider.'
Slider is my IBOutlet (which is connected to the view controller)
I found a lot of same problems on the internet, but all solutions not works for me :(
The load code:
NSArray *xibViews=[[NSBundle mainBundle]loadNibNamed:#"PopoverSetFont" owner:self options:nil];
What should I try?
After 2 hours, and when I ask this question, found a problem. I do not delete a question, I share it, I hope it helps.
So instead of the [[NSBundle mainBundle]... line, use this for load:
PopoverSetFont *popoverView=[[PopoverSetFont alloc]initWithNibName:#"PopoverSetFont" bundle:nil];
This looks like a basic IB error but it hasn't worked out to be.
*** Terminating app due to uncaught execption 'NSUnknownKeyExecption', reason:'[<TrailersViewController 0x585e8e0> setValue:forUndfinedKey:]: this class is not key value coding-compliant for the key myImageView.'
myImageView isn't in TrailersViewController it's in
another object that is on TrailersViewController.
myImageView does not have any IBOutlets.
Third it seems that you can have this problem when pushing view
controllers but it's object is shown in a subview.
myImageView is just a local variable in the object.
Also I had this working but noticed my TrailersViewController was rather leaky so I'm re-organizing it to stop those leaks.
I'm at a loss at the moment but any other directions I could head in would be awesome.
It seems like you have associated the myImageView view in the nib to a #property IBOutlet called myImageView inside TrailersViewController, but you have forgot to #synthesize this property.
So when the runtime tries to assign the myImageView object loaded from nib to the myImageView instance using key-value approach it doesn't find the setter method has you didn't synthesize it.
I would like to display popovers with UITableView's as content (this works) on some button presses and then get the selected item as string as buttontitle or some textview text. I've found a few example on how to do this with protocols but still get an error.
My code:
In popoverViewController.h
#protocol popoverViewControllerDelegate <NSObject>
-(void)getRowText:(NSString *)string;
#end
I declare an id delegate2 variable and set its property to:
#property(nonatomic,assign) id<popoverViewControllerDelegate> delegate2;
In the popoverViewController.m file I synthesize the variable, and in didSelectRowAtIndexPath method I have this, and this line seems to cause the error I`m having:
[self.delegate2 getRowText:[someArray objectAtIndex:indexPath.row];
In mainViewController.m I add the popoverViewControllerDelegate to the ViewControllers protocol and have its header file imported. And then have some code in the -(void)getRowText: method which doesnt get called.
UIPopovers and such are set up as they work as needed, problem arises when I press a row in the tableview. I get the
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'* -[UIPopoverViewController
getRowText:]: unrecognized selector
sent to instance 0x57ca80'
Could anyone give some advice with this?
Finally found the error and cant believe how silly I/it was.
I had a viewController.delegate2 = self. line with period instead of a semicolon, I wonder why it compiled tho.