Rajat
Rajat

Reputation: 1388

Adding subviews to NSView

I want to add subview to NSView dynamically. I set the coordinates of NSView as :

NSView *tmpView = [[NSView alloc]initWithFrame:self.view.frame];

I want to add dynamic number of imageViews to tmpView. My imageView is as:

NSImageView *tmpImageView = [[NSImageView alloc]initWithFrame:CGRectMake(xAxis, yAxis, 320, 180)];

Here, xAxis and yAxis are for positioning of imageViews dynamically.

When i add image view to NSView as:

[tmpView addSubView:tmpImageView]

It adds imageView from bottom left corner but i want it to start from top left corner. Please help how can i add subViews accordingly to NSView.

Thanks in advance

Upvotes: 0

Views: 2041

Answers (1)

jemmons
jemmons

Reputation: 18657

The easiest way is to subclass your view and override -isFlipped to return YES. See the NSView documentation where it says:

-(BOOL)isFlipped
Returns YES if the receiver uses flipped drawing coordinates or NO if it uses native coordinates.

Upvotes: 1

Related Questions