incompatible pointer types assigning to 'UIImageView*' from 'UIImage*' - uiimageview

Hi I am getting this error on my code, I have no clue how to fix it .
Suggestions and answers would be awesome. Thanks :D

The correct syntax would be:
editViewController.chosenImage.image = self.Image

Very much understood from the error that you are pointing UIImage to UIImageview that is not compatible. So You need to use the property image of UIImageview as follows:
[editViewController.chosenImage setImage:self.Image];

All the other answers are correct but it's worth explaining that UIImage is just an object. It is a direct subclass of NSObject. UIImageView is a view (subclass of UIView) that takes a UIImage as one of its properties and displays it.

Related

Change dots of UIPageControl from a ChildViewController in a ParentViewController - swift

I am trying to change the dots in a ParentViewController in function of which ChildViewController appears but I didn't find how to do it. (in swift)
Any idea ?
Here is a gif to give you a better idea :) http://gfycat.com/WarmUglyAppaloosa
I finally found the solution in this post which has a different goal but work in my case too ! https://stackoverflow.com/a/21048603/5164509

Which Cocoa Animated NSView Subclass is it?

I try to figure out, which NSViewSubclass is the overlapping one :
[[NSView Animated Overlap]]
Have you got any idea ?
I hope it's a Cocoa NSView Subclass... and if it's not, I would create a NSAnimated subview.
Thank you !
Have a look at NSPanel which does what you seem to be looking for
Ho, nice !
Actually, I never thought NSPanel would be used like that...
how-to-create-a-nspanel-modally-popuped-from-nswindow-cocoa-programming
Many thanks !

Remove border from NSScrollView/NSCollectionView

As you can see in the screenshot below, the NSCollectionView I used has some kind of border (the thin gray lines) I want to get rid of. Can somebody tell me how to achieve this? I already tried subclassing the NSCollectionView and tried to overwrite it in the drawRect: by using [[super layer] setBorderWidth:0.0f]; but this did not work.
Searching on Google, SO and the Apple Documentation did not help either. So did anyone achieved this already or knows where I can find an example of how to do it?
Thanks in advance,
Björn
The collectionView is nested in a NSScrollView, which has a borderType property.
You can get rid of the border by simply setting its border type to NSNoBorder.
self.collectionView.enclosingScrollView.borderType = NSNoBorder;
From story board:
Select the scroll view from story board
Then choose no boarder from Attributes Inspector
For Swift 3 :-
collectionView.enclosingScrollView?.borderType = .noBorder

Adding a Clear Button to a UITextview

I know I need a UIButton to create an action to clear the content in the UITextView.
I don't know what the code is to actually clear the content in the UITextView.
If anyone has any code for this, I would greatly appreciate it.
Thank you
How about :
mytextView.text = #"";

How to change the image inside an imageview? xCode 4.2

I've been looking for hours now and i cant find a solution. i have an imageview, i have declare it as an IBOutlet, inside that imageview i have already put an image using the interface build of xCode 4.2.
Now my quesion, whats the line of code that it can change the image of the imageview?
The old ones like UIImage *image = [UIImageView imageNamed:#"image2.png"];
its not working because it says that *image is unused variable. it also gives me error at imageNamed it says No known class method for selector 'imageName'
Whats the new code in 4.2? or is it me doing something wrong?
myImageView.image = [UIImage imageNamed:#"image2.png"];
That should do it. UIImageView has an image property that you can set, either as above, or using the -setImage: method that the property provides. Also, from the docs:
Setting the image property does not change the size of a UIImageView.
Call sizeToFit to adjust the size of the view to match the image.
Your other questions:
its not working because it says that *image is unused variable.
In the code you provided, you're assigning the image to a local variable. If you don't then do something with that variable, there's no point in that code. Instead, assign the image to the image property of your image view, as described above.
it also gives me error at imageNamed it says No known class method for selector
'imageName'
That just looks like a typo in your code. The lack of a 'd' in 'imageName' is surely the problem.
Whats the new code in 4.2?
Nothing has changed with respect to setting the image of an image view, as far as I know. I think you've just got a couple little issues in your code.
It's you doing something wrong. You are mixing up UIImage and UIImageView classes. The former is for representing image data in memory. The latter one is representing UIImage instances in a view.
You should change your line to:
imageViewOutlet.image = [UIImage imageNamed:#"image2.png"];
Notice that I'm using UIImage class to assign the image to UIImageView's image property.
You are trying to declare a new variable and not using the ivar you declared with the IBOutlet
You need to assign
[UIImage imageNamed:#"image2.png"]
to the image property of the ivar of the IBOutlet.
For example if your IBOutlet is defined:
#property (nonatomic, strong) IBOutlet UIImageView *imageView;
assign like so:
imageView.image = [UIImage imageNamed:#"image2.png"];
This Works fine for me. oldImage is the IBOutlet of UIImageView. The setCellImage method is inside the Custom UITableViewCell Class.
- (void)setCellImage:(UIImage*)newImage{
[self.oldImage setImage:newImage];
}

Resources