iOS landscape mode & positioning elements

This is a documented note to myself and to others who might be pulling their hair out a little when working with a landscape orientation in iOS.

I was working in landscape mode (only) and I was positioning things around based on frame origins, and I was finding my placements were off. To get into landscape, auto resizing masking is applied to the view(s). However in viewDidLoad is too early to count on anything to base calculations upon. Use viewDidAppear instead. viewWillAppear is also too soon. I forgot about this method since I almost never seem to need it and it’s not part of the default Xcode template for a view controller. I spent nearly an hour wondering what the hell was going on – simple math right? How can it be off like that?

My doh moment for this Friday. I can’t stand when I miss things like this and just piddle coding time away chasing something so rudimentary.

UIPanGestureRecognizer starting touch point

The UIPanGestureRecognizer is a very handy gesture recognizer. It gives us velocity, it had various states, and it can form the basis for some interesting interactions in your iOS applications. One thing it’s not very good at is telling the developer the initial touch location for a recognized pan operation.

By the time UIGestureRecognizerStateBegan is fired, the user’s finger has already moved a bit to actually trigger your delegate method. Depending on how fast the user moved the pan initially, that CGPoint could be fairly close or pretty far away from the actual starting position.

I have been working on a system that connects iOS devices and panning on a control application will affect the others in certain ways. And I needed to know the exact starting position even before the panning was recognized. Since I entered the convenient world of gesture recognizers in iOS I had nearly forgotten about touchesBegan, touchesMoved, and touchesEnded.

Pair the UIPanGestureRecognizer with touchesBegan and you’ll have exactly what you need. In my case I had an area to accept the touchesBegan from, so instead of using hitTest I did something like this which works very well:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint locationPoint = [[touches anyObject] locationInView:self.view];
    CGPoint viewPoint = [trackPad convertPoint:locationPoint fromView:self.view];
    if([trackPad pointInside:viewPoint withEvent:event]){
        NSLog(@"--> %.2f", viewPoint.y);
    } else {
        NSLog(@"touched outside trackpad");
    }
}

Wonderful.

Trespassing? WTF…

Today I was cleaning out our basement – we have a lot of old stuff in boxes down there. We rented a dumpster and it’s out front beside our driveway (we have two driveways, it was on one of them next to the house). So I took out some stuff and also put a big newborn rocking chair out there (it’s for the mother to help rock an infant in while feeding, etc.) That chair is very heavy and it took me a while to get it in there. I am taking the stuff out of our basement back door and around to the dumpster.

Fast-forward 30 minutes of me gathering up more things to throw away and I am making my way around the house again with more boxes and what do I see? That big heavy chair against the back of our house in the snow. Wha?! A really strong ghost – or someone taking our refuse?

I see heavy boot prints around in the snow and they sure aren’t mine. I go back in and I get my Kabar and walk around the house – looking for prints by any windows, the back-door, etc. Nothing – but since I’ve made so many tracks I decide to run through the house, Kabar at the ready. Nothing.

So I now assume some asshole went through our dumpster and put the chair behind our house to hide it so he can come back to get it. Is dumpster-diving a common thing? Were they worried someone else would take it? It’s not dark yet, but I know if they hid it and they are coming back, they will do so before the sun goes down. They wouldn’t want suspicious headlights in our driveway, right?

I continue taking out load after load of stuff to the dumpster, listening for any sounds of movement generated outside my area of influence. I then decide to put the chair back in the dumpster. I figure why do I want someone creeping around my house again – if they want the chair they will have to get it out of the dumpster again. Incredibly creepy!

It’s starting to get dark (it’s now 3:50PM) and I hear voices as I am coming around the side to the dumpster with another load. Two guys are inside the dumpster taking the chair out again. I drop the stuff I was carrying so I can free my hands in case I have to go for the Kabar. Who knows – lots of weird people out there. I ask them what the hell they are doing, etc. One guy plays smart cop to the other dumb cop, “I told him we should have asked before taking this… it’s rude, right?” To which his friend says, “But I can’t resist this stuff. I put it in your backyard so no one else could take it.” I told them to take it but to get the hell out off my property.

A guy says they knocked on the front door to ask, but that’s a lie – I would have heard that. Then he says he didn’t think anyone would be around to ask. I tell them to hurry up and just take it. Truth is that taking it has freed up room in the dumpster. So I wasn’t going to be a prick and say no. Besides, I figured they would come back sometime and get it anyway. Let’s just end this.

The second guy looks at me and says, “Looks like you have a lot of kids stuff here. My friend lives around here and I know a lot of the kids. They love toys.” The look in this dude’s eyes when he said that was truly weird… like he is or was pretending to be harboring pedophile tendencies. My hand went to the butt end of the knife, but I didn’t reveal it.

I told him that our kids are grown up now and this is just old stuff we’ve never gotten around to throwing out. I don’t want that douche thinking about my kids.

They took a while to rope down the chair in the back of a white Chevy pickup truck. The one guy was apologizing – but I told him his were the bootprints around to the back of the house. He didn’t say much after that.

When they were done, I made my way around to the back of the house, but first I snapped a picture of the truck and one of them with my phone. It was from fairly far away, but just in case I might need it.

What do you think about this situation? I think it’s pretty messed up and the fact that they thought it was okay to do makes me wonder. I don’t know if I am overreacting or not. It’s a bad economy and they might use the chair, or fix it up for eBay, etc. I just hope that I don’t see them again.

I am another test post

I should be posted sometime after the first test post scheduled. 2:35PM EDT to be precise.

Test caption.


Wireless charging for iPhone 5 comes when exactly?

I would enjoy a wireless charging system for my iPhone 5 (and potentially a few other devices – a mat large enough for an iPad mini would be extra nice) to make night-time charging at home more elegant. USB cables sprouting from an outlet definitely works but it’s messy looking.

Duracell Powermat

The Duracell Powermat is something what I am after – I’ve checked on their solutions and they have something coming soon™ whenever that is. Anyone have any insight into this? While Binging (I don’t do the Google thing as much anymore – an evil topic for another time), I discovered that Apple has applied for a patent in this arena.

Apple states that their patent covers methods, systems, and apparatus for interacting between a plurality of peripheral devices receiving power wirelessly from a wireless power supply. In one embodiment, a virtual charging area could be created. The virtual charging area will be able to extend to about one meter (3 feet) from a central station that incorporates a NFMR power supply.

Continue reading

iPad mini review

I didn’t receive my 16gb iPad mini until the Thursday after Christmas because it had to be shipped and there was a serious run on them, etc. I had given my old iPad away and I simply restored from an iCloud backup. I have been using it since.

Siri on the iPad is pretty nice. I use it on my iPhone quite a lot, mostly for reminders, appointments, iMessage, etc. when you need it, it’s pretty great. Same on the iPad.

The size. I do have to admit to sometimes missing touch targets every now and then because of the decreased size of UI elements. Nothing major, but even when it happens once its a pain in the ass. The keyboard has never given me problems, it’s areas within applications. So that bit isn’t the most fun. I can put this into a back pocket, with the fear of sitting down forgetting its there. It’s quite portable and every bit an iPad.

The screen. It’s not quite retina, but its something I haven’t noticed very much to be honest. Every now and then I might see some white text on a black background that is small enough to make it blurry. Quite rare. The screen is decent and utilitarian. I have no qualms.

I use the iPad even more now, and I plan on using it at work for taking notes, etc. even more than I do with an iPad 3 that I have kicking around there. Lugging it was always the drawback.

More as I continue to use it, but I love it. Writing this now in landscape on it right now