Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,706
6,289
I'm trying to find the center of a view with:

Code:
currentY = activeSuperview.center.y;

but I get this error:

error: request for member 'center' in something not a structure or union.

activeSuperview is declared as an id (I didn't know what else to declare it as,) becuase it'll change based on which UITextField is currently selected.

Code:
activeSuperview = [textField superview];
 
It'll still be a UIView. So instead of id you can declare it as UIView *

Unless the text view doesn't have a super view of course...
 
*dope slap* thanks. I had tried calling it a UIView originally but it gave me an error (I can't remember what it was.) I had assumed it was because I tried calling it a UIView but the real issue was I left out the *.

Next issue...

I'm trying to move the superView (the idea is that the textField won't be obscured by the keyboard when it comes up.)

Here's my code along with the error that I get...

Code:
- (BOOL) textFieldShouldBeginEditing: (UITextField *) textField
{
	activeSuperview = [textField superview];
	
	if (textField.bounds.origin.y > 244)
	{
		activeSuperview.bounds.origin = CGPointMake (160, (activeSuperview.bounds.origin.y - (textField.bounds.origin.y - 244)));
error: invalid lvalue in assignment
Code:
	}
	
	return YES;
}

It's supposed to move the superview of the textfield so that it isn't obscured by the keyboard when it's being edited. Is there an easier way to do it?
 
What happens if you make a new CGRect instead of a CGPoint? Accessing the origin CGPoint directly like that seems a bit fishy to me.

Edit: and I think you're looking for the frame, not the bounds. IIRC, frame is relative to the superview, and bounds and local. So the origin of the bounds will always be 0,0.

Dave
 
What happens if you make a new CGRect instead of a CGPoint? Accessing the origin CGPoint directly like that seems a bit fishy to me.

Edit: and I think you're looking for the frame, not the bounds. IIRC, frame is relative to the superview, and bounds and local. So the origin of the bounds will always be 0,0.

Dave

:)

Thanks. Using the frame instead of bounds and a rect instead of a point worked perfectly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.