When resizing a UIView has no effect …

Posted at 21 May 2014
Tags: ios, development

… one should better look whether the method to change the view’s dimensions and/or position (e.g. -[UIView setFrame]) is called from the main thread or from somewhere else. In my case, I was calling the setFrame method from a different thread because the method invocation was inside a delegate method. Whatever I tried, the UIView’s size would not change and no error or warning was issued. Luckily, I stumpled upon the different caller’s thread name in the debugger. The solution was then to use the method -[NSObject performSelectorOnMainThread] to call a method that sets the new frame size from inside the main thread. However, this is a mistake that’s rather hard to spot. Some kind of warning or error would be nice in this case.

If you spotted a mistake or want to comment on this post, please contact me: post -at- mkonrad -dot- net.
← “Master's thesis featured on gpgpu.org
View all posts
My master's thesis is online” →