Lvalue required as the left operand of the job

Hello, I get the error "Lvalue is required as the left destination operand" in xcode. What for? Here is my code (window1 / 2 - UIViewController):

- (void)loadView
{

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,460)];
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,640,460)];


    self.window1 = [TweetViewController alloc];
    self.window2 = [InfoViewController alloc];


    [contentView addSubview:self.window1.view];
    self.window2.view.frame.origin.x = 320; //HERE IS THE ERROR!!
    [contentView addSubview:self.window2.view];


    [scrollView addSubview:contentView];
    scrollView.contentSize = contentView.frame.size;


    scrollView.pagingEnabled = YES;


    self.view = scrollView;


    [contentView release];
    [scrollView release];
}

Thank you for your help.

+5
source share
3 answers

The part self.window2.view.framewill leave you with the getter, without actually reaching the inner frame CGRectand capturing it. What you need to do is get CGRectchange it and then set it back into the view.

CGRect f = self.window2.view.frame; // calls the getter
f.origin.x = 320;
self.window2.view.frame = f; // calls the setter
+15
source

You must set the frame as a whole:

CGRect f = self.window2.view.frame;
f.origin.x = 320;

self.window2.view.frame = f;

See properties .

+2
source

( ...); (Γ  la epatel) , cold.

But I have a macro that allows you to do this

    @morph(self.window2.view.frame, _.origin.x = 320);
    [contentView addSubview:self.window2.view];
0
source

All Articles