Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created April 4, 2013 13:03
Show Gist options
  • Save Dimillian/5310171 to your computer and use it in GitHub Desktop.
Save Dimillian/5310171 to your computer and use it in GitHub Desktop.
CellSize size;
if (_list) {
size = CellSizeList;
}
else{
//TODO: Factorize landscape/portrait code
//Randomize cell size and avoid hole
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])) {
if (_currentRowStatus == CellRowEmpty ||
_currentRowStatus == CellRowOneSpaceUsed) {
int randomInt = arc4random() % 2;
size = (CellSize)randomInt;
}
if (_currentRowStatus == CellRowTwoSpaceUsed){
size = CellSizeOne;;
}
int newRowStatus = _currentRowStatus + 1 + size;
_currentRowStatus = (CellRowStatus)newRowStatus;
if (_currentRowStatus == CellFullRow) {
_currentRowStatus = CellRowEmpty;
}
}
else{
if (_currentRowStatus == CellRowEmpty ||
_currentRowStatus == CellRowOneSpaceUsed) {
int randomInt = arc4random() % 2;
size = (CellSize)randomInt;
}
if (_currentRowStatus == CellFullRow ||
_currentRowStatus == CellRowTwoSpaceUsed){
size = CellSizeOne;
}
int newRowStatus = _currentRowStatus + 1 + size;
_currentRowStatus = (CellRowStatus)newRowStatus;
if (_currentRowStatus == cellFullLandscapeRow) {
_currentRowStatus = CellRowEmpty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment