English 中文(简体)
• 如何避免“特例”处理“UIScrollView with OrientationDidChange on appstarte”
原标题:How to avoid "special Case" when dealing with paging a UIScrollView with OrientationDidChange on app starting

因此,为了处理方向变化(从某种观点看,不是控制者),我们在UIDeviceOrientationDidChange通知中登记。 所有这一切都是好的。

It gets called on app startup, reporting the correct dimensions but incorrectly saying something changed (due to having landscape views or other software-reasons this may be triggered).

在少数不必要信息之后,它将开始发出合法信息。 该装置将报告正确的“取向”,但它仍然给出目前框架(和约束)无效。

To scroll the page to the right, other SO questions lead me to remember to manually set the contentOffset, which has most of what I need. currentPage = current Y offset / width of scrollview. Basic math, cool.

这确定了我的大部分问题。 就适当的业务协调办公室而言,我对一项延期职能表示意见,而这一职能恰恰是“iPad”的大小,因为“iPad”是一个表层,我这样做:

float currentDeviceWidth = 768;
float currentHeight = 949; //logging the frame from portrait, landscape = 1024 w, 693 h
UIDeviceOrientation o = [[UIDevice currentDevice] orientation];
if (!UIDeviceOrientationIsPortrait(o)) {
    //landscape
    currentDeviceWidth = 1024;
    currentHeight = 693;
}
else
    NSLog(@"Moving to port, unless on startup, then its staying as");

Which handles the orientationDidChange: messages, but when the app starts, the scroll view is now smaller than it should be because it set its size as if the bounds it s getting are "about to change", when they re not.

Possible solutions: a) [self performSelector:@selector(relayout) withObject:nil afterDelay:delayNum];

b) 在确定“BOOL dontIgnoreLayout”之前,给予一定时间的拖延。

c) Find another way to test for orientation

d) 手工操作,发现最初发送的所有信息,消除所有原因,只有在该系统没有设立时,这一选择才有可能。 我可以用一个新项目来检验,尽管它掌握了企业情况,但如果是这样的话,它可能还会有点窃取。

Wondering if anyone solved this. If not, I have to put in "special case" or "time based" code, neither of which are OO style, at least not my preferred way (nor my coworkers).

如果我错过了有关SO的内容,让我知道,但正如你能够看到的那样,我迄今找到了一些答案。

Thanks

问题回答

我以其他人为榜样,对“地位BarOrientation”进行测试,这似乎总是正确,并且显示与“UIDevice”目前的方向有矛盾的信息。 我知道这一点以前已经找到了,但确定问题的具体原因是:

As per suggestions in other threads, I registered for notifications in ViewDidAppear and not viewDidLoad, this combination seems to be the win.





相关问题
paging next and previous links don t work!

can anyone help me with this code?the next and previous links don t work $limit=20; mysql_connect("localhost","root",""); mysql_select_db("autoschool") or die("Unable to select database"); $query = "...

Please help me with ASP.NET MVC Paging error

I am getting the following error in my mvc application when I am doing the paging functionality CS1061: System.Collections.Generic.IEnumerable does not contain a definition for HasPreviousPage ...

How to do paging in the mvc grid?

Any suggestions on how to do paging in the mvc grid, in an easiest possible way? Please point me to sample code, if any

What s the best method to do paging in my ASP page

What s the best method to do paging in my ASP page when displaying a list of items? I knew that there is no equivalent to MySQL s LIMIT clause present in SQL Server, either 2000 or 2005. How can I ...

linq paging - get total rows

i have a question about linq. I m using Skip and Take to do paging: (from l in db.ProductList select l).Skip((page - 1) * row_per_page).Take(row_per_page) It work, and i need retrieve ...

Java, Page through array

Test[] array = new Test[3]; array[0] = new RowBoat("Wood", "Oars", 10); array[1] = new PowerBoat("Fiberglass", "Outboard", 35); array[2] = new SailBoat("Composite", "Sail", 40); I have ...

Mod Rewrite Optional Parameters

I have a fairly complex set of rewrite rules to give my site pages pretty URLs. Right now to deal with paging of search results I m using 2 rewrite rules: RewriteRule ^search/([0-9]+)$ /cgi-bin/...

热门标签