Mostrando postagens com marcador iphone/ipad. Mostrar todas as postagens
Mostrando postagens com marcador iphone/ipad. Mostrar todas as postagens

terça-feira, 27 de setembro de 2011

iOS Quick Tip - Turning Off Automatic Reference Counting aka ARC

When developing your new apps under the newest XCode beta with iOS 5 you`ll get the ARC as gift, ok not a full git YET, but still a powerful gift.
So the question(s) arises: "What to do with code that isn`t under ARC yet?", "Can I turn it off?", "Can I turn it off only in a few files?"

Easy now, that is not a big trouble, I do hope that Apple engineering team improve this but for now let`s stick with what we got.

Turning ARC off for a new project (XCode Preview 7 onward *we hope*)

This is the easiest way, when creating a new project just check/uncheck "Use Automatic Reference Counting"


Turning it off for a few files
I`m personally not a huge fan of compile parameters but at least we have then when nothing else help us.
So open your project and select your desired target. Then select Build Phases, expand Compile Sources. There you`ll find the files that XCode is compiling, select everyone that will not use ARC and hit "enter". In the white box type -fno-objc-arc and hit enter. Done!



That`s all we need to stop using ARC in some of our project files, and whenever you change your mind just remove the flag.





sábado, 17 de setembro de 2011

iOS Quick Tips - Flip Animation

Whenever you have views in your fancy applications you`re probably thinking about some animations to make navigation smoother between some screens or between views.
Let`s imagine that we are building a card based game and that at some point we want to touch the card and it`ll flip revealing it front side.

Start by creating a new project on xcode. File > New > New Project or simply command+shift+N.
Select single view application and click next. Fill the info in the next screen, don`t check anything and let iphone device selected.

Create two new files a view nib and a view controller named FlipAnimationCardView and FlipAnimationCardViewController.
After creating them open the nib and attach its file owner to our view controller and attach our root view to the view controller.
After it you can put two UIButton, make them fullscreen with different image in each one, them link them and its touch up actions to our view controller.
The video bellow show how to do these steps.



Now we can place our animation in action with onCardBackTouched and onCardFrontTouched.
UIView has a static methods for animation, we`ll use transitionWithView but you can play with animateWithDuration too.



In the code above we are saying to the UIView class that we want a transition using btnCardBack during 1.5 seconds and we are setting the animation to be a Flip From Right type and telling the UIView to animate it with a EaseInOut curve so it will be smooth. There are more options and you only need to separate the parameters with | so the function identify what it have to do.
During the animation we ask the view to change btnCardBack and btnCardFront alpha property to 0.0 and 1.0, so it will vanish from the screen showing the front part (btnCardFront).
Every property that can be animated and is inserted into animations block will be animated by the UIView method.

The code above only animate our back part of the card, how can we animate its front card at the same time so it will appear like we are really flipping it?

We need to add this second part, the same code but passing btnCardFront as the view to use in the transition.



From here you can insert this into onCardBackTouched and the result should be 



Before we go testing lets tie app delegate to our new view controller so it`ll appear when the app execute.

Your appdelegate.h should be like this



In the .m file your didFinishLaunching method should be similar to this


Now build your code and test it on the simulator, you will see the card flipping nice and smoothly, but when you touch it again nothing happens, why? Because we didn`t created any animation to make it flip back. To do this insert the following code into onCardFrontTouched



If you execute it at this stage you will see the card flip back after you see the front part, very nice and not so hard to do. This code we made works for both fullscreen and not-fullscreen cards, but there is a shortcut for fullscreen cards.

Change our touch actions code to be like this



Cleaner than before but doesn`t work for cards smaller than the screen the reason is that transitionFromView:toView: animate the view and its parent.

Now to the last golden egg, what if we want the card to flip automagically after some time? We have two options performSelector and NSTimer, the first one will call our method after a time delay the second is a timer that can be scheduled to happen and have a loop parameter.
They have its pros and cons and I`ll not discuss this right now and for this tip we will use performSelector.
I decided to use viewWillAppear, but you can call your performSelector or register your timer wherever you want.

Add viewWillAppear to you view controller or code the performSelector inside it passing onCardBackTouched as parameter



Build and play with it, you can go further and flip it back automagically, insert multiple cards, make a category helper class to call this code from a view instance or something similar, just have fun!





quinta-feira, 7 de julho de 2011

Competição E-games do Senac

 O e-games é um concurso cultural que promove o desenvolvimento de jogos eletrônicos (vulgo game para os íntimos) e está em sua 3º edição. Recomendo participar pela experiência, visibilidade e principalmente diversão.
Segue uma parte das regras de participação e os prêmios.


e-Games - Concurso de Desenvolvimento de Jogos Digitais do Senac São Paulo (3ª edição)
Mais informações do evento e todo o regulamento consta no site e-games
Participantes:
Poderão participar do e-Games pessoas físicas maiores de 14 (quatorze) anos, com cidadania brasileira e residentes em todo o território nacional, individualmente ou em equipes com até 3 (três) integrantes, com qualquer nível de escolaridade e atuando em qualquer área do conhecimento.

Os participantes devem concorrer com apenas 1 (uma) única inscrição e com jogos que ainda não concorreram ao e-Games em edições passadas. Os jogos e seus documentos auxiliares deverão ser desenvolvidos obrigatoriamente em língua portuguesa. Caso o participante tenha feito sua inscrição individualmente, não deverá também fazê-la como integrante de uma equipe e vice-versa.

Categorias:
A participação no e-Games deverá acontecer de acordo com as seguintes categorias:

5.1. Categoria Vídeo Game & PC
Os jogos desta categoria devem ser obrigatoriamente criados para rodar em uma das seguintes plataformas:

·         PC - Windows Vista
·         PC – Windows 7
·         Video Game - XBOX 360

Eles podem ser desenvolvidos utilizando qualquer tecnologia, como por exemplo:

·         XNA
·         C
·         C++
·         Flash
·         Java
·         Silverlight


5.2. Categoria Mobile
Os jogos desta categoria devem ser obrigatoriamente criados para rodar em uma das seguintes plataformas:

·         Mobile – Iphone
·         Mobile – Windows Mobile 6.5
·         Mobile – Windows Phone 7.0

Eles podem ser desenvolvidos utilizando qualquer tecnologia, como por exemplo:

·         XNA
·         C
·         C++
·         Flash
·         Java
·         Silverlight


5.3. Categoria Jogando na Nuvem
Para esta categoria os jogos podem ser criados em qualquer linguagem e podem rodar em qualquer plataforma. A única exigência é que o jogo tenha uma integração com Windows Azure, utilizando a plataforma de Nuvem da Microsoft, o que pode ou não contemplar SQL Azure.

Premiação:

1° lugar – Categoria Vídeo Game & PC
XBOX  360 
Troféu e-Games 2011

1º lugar – Categoria Mobile
 Ipad 2 
Troféu e-Games 2011

1º lugar – Categoria Jogando na Nuvem
XBOX com Kinect
Troféu e-Games 2011

2° e 3º lugares de todas as categorias
Troféu e-Games 2011
Livro da Editora Senac  

segunda-feira, 2 de maio de 2011

Quick Tip - IOS DEV - UIColor

This is a good fast tip for ios newbies (like me)....I was trying to use UIColor to create a color with RGB values like this:

But this natural approach is wrong and if you read Apple class reference here (as I did) you probably will realize that each color must be between 0 and 1....what a damn confusion uh Apple...

For those that didn't realize it before just divide it by 255 and everything goes well:

That's it folks!!!