Apple normaly gets things right about improving their hardware and software, but in regards of devs support some times things don't go quite well.
One of this samples is the last iTunes Connect update (Xcode 6 / iOS 8 in 2014) which changed something on how they expect your images to be uploaded and made a bunch of us quite sad.
If you have the same problema as me you were receiving this message: "Images can't contain alpha channels or transparencies."
By the time this problem came to me the design team have already tried almost everything they could think of, and I went to a simple path of looking in the net one last time.
So I got to this stackoverflow post, and Smikey anwser solved my problem.
He simply suggests that we re-export the asset using Preview with Alpha option unchecked. By the way we were using a .png image.
Thats it problem solved.
Hope this help you ;)
Mostrando postagens com marcador ios. Mostrar todas as postagens
Mostrando postagens com marcador ios. Mostrar todas as postagens
segunda-feira, 29 de setembro de 2014
sábado, 2 de agosto de 2014
[Quicktips] iOS - Follow Keyboard Animation Behaviour
On getting back to iOS programming I restarted to check into interesting subjects, like the right way of creating view controllers, behaviours and more.
One thing I had to create these last days was some code for a text field to follow the keyboard open/close animation. Then it come to me that we were going to use that behaviour was needed in more places and that it didn't belong to the view controller neither to the view using it.
So in order to achieve that I decided to create a behaviour class which features are:
To achieve our desire the class must subscribe to keyboard notifications and follow keyboard info dictionary in order to animate the same way the keyboard does.
In 1. we retrieve the type of animation, the duration and the final position of the keyboard. The problem with the animation type is that Apple uses a internal value which only works directly with the old animation style.
To use it with animationWithDuration methods we would have to shift the value, this isn't easy to understand and read later so is preferable to keep the old style in this case.
In 2. we use the animation calls on UIView to prepare animation with keyboard info.
In 3. we animate using the keyboard final position, in my case I'm positioning the view right above keyboard, and when dismissed the view will be hidden outside of the screen in the bottom. Also we have to commitAnimations so evertyhing will work properly.
That is all we need to create a behaviour that works with any view.
The class and the demo are available on github.
One thing I had to create these last days was some code for a text field to follow the keyboard open/close animation. Then it come to me that we were going to use that behaviour was needed in more places and that it didn't belong to the view controller neither to the view using it.
So in order to achieve that I decided to create a behaviour class which features are:
- To receive a target view
- Register under keyboard events
- Animate the target view to follow the keyboard open/close animation
- Keep target view before (on top) of keyboard, meaning that target will be hidden when keyboard is closed
To achieve our desire the class must subscribe to keyboard notifications and follow keyboard info dictionary in order to animate the same way the keyboard does.
In 1. we retrieve the type of animation, the duration and the final position of the keyboard. The problem with the animation type is that Apple uses a internal value which only works directly with the old animation style.
To use it with animationWithDuration methods we would have to shift the value, this isn't easy to understand and read later so is preferable to keep the old style in this case.
In 2. we use the animation calls on UIView to prepare animation with keyboard info.
In 3. we animate using the keyboard final position, in my case I'm positioning the view right above keyboard, and when dismissed the view will be hidden outside of the screen in the bottom. Also we have to commitAnimations so evertyhing will work properly.
That is all we need to create a behaviour that works with any view.
The class and the demo are available on github.
Marcadores:
behaviours,
design patterns,
ios,
mobile,
objective-c
sexta-feira, 15 de fevereiro de 2013
[iOS] Using UIRefreshControl
In iOS 6 Apple presented us the UIRefreshControl to use with "Pull to Refresh" actions. This control is really easy to use and can be currently used with UITableView, UIScrollView and UICollectionView.
On your -(void)viewDidLoad method or the place where your controller will load for the first time, create and add the refresh control as a subview of the views mentioned above.
The next step is to create the refreshView method, just add it anywhere on your view controller.
That is it, nice and smooth.
On your -(void)viewDidLoad method or the place where your controller will load for the first time, create and add the refresh control as a subview of the views mentioned above.
The next step is to create the refreshView method, just add it anywhere on your view controller.
That is it, nice and smooth.
Marcadores:
ios,
objective-c,
uirefreshcontrol
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.
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.
Marcadores:
automatic reference couting,
development,
ios,
iphone/ipad
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.
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!
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!
Marcadores:
animation,
desenvolvimento,
games,
ios,
iphone/ipad
domingo, 8 de maio de 2011
Quick Tips - IOS Dev - Documentation Shortcut
This tip was given me by @marcolindoso, one of my co-workers and friend at Parsec Digital.
Most of the times Apple documentation is very useful but we have to copy the code and go to google or the Apple site, so instead of doing this we can use xcode sdk docs. Ok nice idea but the shortcut its too dificult to remember or even to guess if you don't look for it in preferences.
So let's change this:
With XCode opened enter in Preferences (Type: command + ,)
Open key bindings and type "Documentation" in the search field, now you gonna see a list and in that list is the key binding "Search Documentation for Selected Text", select it and type enter
When the key binding open for editing input command + D
Done, now you have easy to remember shortcut for documentation access, to use it put your cursor over any piece of apple documented code and use the shortcut.
Happy coding....
Marcadores:
apple,
documentation,
ios,
objective-c,
quicktips,
shortcuts
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!!!
Marcadores:
apple,
development,
ios,
iphone/ipad,
mobile,
quicktips
Assinar:
Postagens (Atom)



