你好我在xcode中得到了“Lvalue required as assignment openg of assignment”错误。为什么? 这是我的代码(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];
}
感谢您的帮助。
答案 0 :(得分:15)
部分self.window2.view.frame
将为您留下一个吸气剂,而不会实际进入并抓取内部框架CGRect
。您需要做的是让CGRect
更改它,然后将其重新设置到视图中。
CGRect f = self.window2.view.frame; // calls the getter
f.origin.x = 320;
self.window2.view.frame = f; // calls the setter
答案 1 :(得分:2)
您必须将框架设置为一个整体:
CGRect f = self.window2.view.frame;
f.origin.x = 320;
self.window2.view.frame = f;
请参阅properties。
答案 2 :(得分:0)