Drag and drop in Windows Phone 7 Mango - drag-and-drop

How do you implement something like drag and drop using (Silverlight) Windows Phone 7 (Mango)?
Ie, I add an image in the center of page, then want to allow the user to move that image around on screen, possibly also resizing it by pinching.

This turned out to be pretty simple as soon as I started playing around with Expression Blend 4!
This code did it really well for moving around:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Image Margin="129,112,167,122" Source="mypicture.png" Stretch="Fill">
<Custom:Interaction.Behaviors>
<il:MouseDragElementBehavior/>
</Custom:Interaction.Behaviors>
</Image>
</Grid>
The key part is that stuff within "Custom:Interaction.Behaviors".
Not sure if this can be used to perform some other custom operations, or do pinching, but I guess it's not too far away?
And this is not only for Mango level Silverlight - I haven't actually installed Mango SDK yet, this should work on earlier versions.
I found out that this doesn't seem to allow more than one image dragged at a time. AFAIK, the iPhone supports 11 fingers touching the screen at once - I once built an application where you could move many things around on screen and it worked well at the same time. Not sure what the limits are for WP7 phones but the Samsung I'm using is probably not limited to 1 touch - this is likely a problem with this code. Someone got a better solution?

In Expression Blend 4, Go to Asset tab --> Behavior --> MouseDragElementBehavior to drag the item.
To resize by pinching, do you mean double click? you could set onMouseLeftButtonUp and set a counter?

Related

Screen sizes in Xcode 7 the using SpriteKit

I am relatively new to sprite kit and have been attempting to create my first basic game. All physics and other basics seem ok, but for some reason whenever I build and run the screen dimensions are off (looks like default is 1024×768)?
Pretty sure I'm missing something fundamental here but it doesn't seem immediately obvious on how to adapt the screen to any size iPhone screen (this is my ultimate goal).
My question is whether this is actually just a setting issue or is it necessary to implement code?
Thanks in advance and have a great day!:)
To answer the first part, you can easily change the size of your scene.
If you take the default GameScene, click out of the scene and look at the Attributes Inspector. You will see the default size of 1024,768. Personally if landscape I tend to work with an iPhone 5 design resolution of 568,320.
Regarding multiple devices, SpriteKit works pretty well out the box. You should look at the documentation regarding scaleMode, take a look in the GameViewController.swift. .AspectFit worked really well, nearly pefect across all devices apart from a little letterboxing on iPad. However, for the amount of effort put in, more than good enough.
On a side note, I've found the following iPhone Resolution Guide resource useful in the past.

iOS - How to show hints for gestures for iOS app?

I have seen some apps where when you launch them for the first time after downloading (e.g. Chrome app on iPhone), it shows you a list of animated gestures on the screen, kind of giving you a tour of the app.
How do I build one something like that? And how does the app know to launch only for the first time after download and not since then? For the second question, I am guessing a "shown=TRUE" value can be saved inside a PList file and checking the value each time when the app finished launching. But I am more curious about the mechanism involved in creating a guided app tour.
You can use transparent and semi-transparent images with a UIImageView, so you can make up an image with arrows and notes and put over the whole screen. You could fade it out when the user taps.
To know if it's the first time running the app, you should use NSUserDefaults instead of a plist; it's much easier, and you should be app to find a quick tutorial on that fairly easily.
Also, you could check around on this site for controls like this one. I haven't used any of them myself, so I'm not sure how much they differ from a regular UIImageView. They look nice though.

How can I use gestures on iPhone apps using Delphi Firemonkey?

I am trying to write an iPhone app using Delphi XE2 / FireMonkey and have got past many of the initial hurdles, but am now stuck on gesture handling.
I have created a test app with a TVertScrollBox, but I cannot scroll the contents, unless I enable the scroll bars (which are very thin), and touch those. This is not very iPhone friendly (and almost unusable). Would appreciate a pointer in the right direction.
Documentation seems to suggest using UIGestureRecognizer...
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html
...however these need to be attached to a View, whereas the app is using a FireMonkey form.
Any thoughts would be appreciated.
I have worked out how to do this...
The TVertScrollBox control needs to have the MouseTracking property set to True.
All controls added to the TVertScrollBox then need to have their HitTest property (if it exists) set to False. After that it just works!
With Delphi Xe3, Fire monkey as support for basic gestures (zoom, rotation, pan)
But officially Xe3 doesn't support anymore "IOS" as a target.
You have to wait beginning of 2013 for the release of their "mobile studio" extension
Gestures not in FireMonkey at the moment.

Windows Phone 7 UI (Metro) possible on iOS?

How hard would be be to recreate Windows Phone 7 UI animations on an iOS device using UIKit?
More specifically, making animated boxes gradually move from side-to-side, and appear in a chained manner.
For example, windows phone 7 transitions here: http://www.youtube.com/watch?v=EUeNCzRhhDE
At 0:30 - the parallax scrolling effect (relatively easy?);
At 1:22 - the chained animation of the home screen;
Is this possible with CoreAnimation and UILayers, if so how complex would it get?
Thanks
It's not incredibly hard. For some things like parallax scrolling you can just use some of the basic view animation code and set different timings for different elements to get the effect.
Look at the animations Apple has in the Apple stores for providing help (similar to some of their screen savers). These are similar to what Windows is doing.
The bigger question would be whether it improves the user experience or just makes them wait longer to be able to interact your application.

Iphone default behaviors that need to be implemented?

When I've learned that I have to write some code to make the iphone keyboard go away. I was quite surprised. I was surprised even more when it become apperent that it is just the top of the iceberg.
What are the expected UI behaviors that aren't provided by system OOTB?
Is the list below complete?
The expected UI behaviors:
Focusing next text field when [done] is hit
Hiding the keyboard when background is hit
Using Touch Up Inside to fire a button action. (To give user opportunity to change his/her mind)
Supporting the screen rotation.
Some of that is silly, but some of it has uses as well.
Focusing next text field when [done] is hit
Which field is "next"? If you have a large form with fields both next to and above/below each other, next might not be so obvious. Even if they are in some linear layout, the iPhone would have to work to figure out which one is next. Do you want to wrap around at the end of the form, or dismiss the keyboard, or submit the form?
Hiding the keyboard when background is hit
I mostly agree with you here, though there are a few cases where this is useless. For example, adding a new phone number in the contact app.
Using Touch Up Inside to fire a button action
This one I really don't get. I can only guess that it's designed to allow you to use buttons instead of the touchesBegan/Moved/Ended methods. I guess it could be useful, but I've never used anything but Touch Up Inside.
Supporting the screen rotation
Many apps just don't work in any other orientation, such as games. If you want to use rotation, you only have to add two lines of code assuming you've done your layout well.
I hope this helps explain some of the strangeness. Aside from the keyboard dismissal, I've never really found anything too annoying. The one thing I wish they supported was using the highlight state of UIButtons for the set state. It would be a quick and easy toggle button, but I've taken to screenshotting a highlighted button and using that for the background image of a selected button.
Want a rounded rectangular button that isn't white? Since that one uses a background image, you can't just click something somewhere that makes it the color of your choice. You have to create your own image or you could even use CSS (WTF!?) to do it.
Unfortunately, the iPhone SDK lacks a lot of helpful things one would think would just be there. However, many people have taken the time to write wrappers for many of these kinds of things to help facilitate development - a quick google search into the functionality you are expecting may turn up a lot of useful answers!
For example, you could make the keyboard go away when you tap outside of it by creating a new view when it appears, and placing that view behind any user-interactable views on the screen. When that new view is tapped, it will become first responder and cause the keyboard to slide away (because the UITextField is no longer first responder).
Such a thing could be easily implemented as a drop-in fix for pretty much anything you'd need it for with very little code.
Still should have been included in the SDK in the first place, though!