ios7 - Beginner's iOS issue (from tutorials) -


this may seem stupid first time trying write ios code , using tutorial tells me add code , explains did few lines later. able create basic square on screen , next few lines make sure square drops bottom of simulator. added , compared code square doesn't drop code should. here wrote.

uiview *square = [[uiview alloc] initwithframe:cgrectmake(100,100,100,100)]; square.backgroundcolor = [uicolor graycolor];   //uicollisionbehavior* _collision;  [self.view addsubview:square];  uidynamicanimator* _animator; uigravitybehavior* _gravity;  _animator = [[uidynamicanimator alloc] initwithreferenceview:self.view];  _gravity = [[uigravitybehavior alloc] initwithitems:@[square]]; [_animator addbehavior:_gravity]; 

can tell me doing wrong? or code incorrect someway? there other simpler way begin ios development

thanks

it works:

@interface dpviewcontroller () {    uidynamicanimator* _animator;    uigravitybehavior* _gravity;    uicollisionbehavior* _collision; } 

your mistake declare _animator, _gravity in viewdidload.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -