Reply to topic  [ 79 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Dipping the toe in - Swift, Xcode, adaptive layouts 
Author Message
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
A bit more progress to share - I’ve started thinking about whether I should be able to change the appearance of the clock depending on the time. This seems to be a feature of some clocks on smart phones/tablets and watches.

So I’ve created a new face:
ImageClick for large view - Uploaded with Skitch

The red dot is the second hand, BTW!

After 6pm and before 6am (these are normal times - I’ll get round to checking the decimal hours later), it should change (I’ve not yet checked that it will do this live, but setting dummy times seems to work) to this:

ImageClick for large view - Uploaded with Skitch

At the moment, it’s just swapping the images, but I expect that I’ll need to actually switch layers on/off in the future to accommodate different sizes (for glows etc).

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Wed Nov 26, 2014 1:13 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
https://plus.google.com/u/0/app/basic/e ... nj2augs760

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sun Nov 30, 2014 5:15 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Fogmeister wrote:
https://plus.google.com/u/0/app/basic/events/ckckuhqb2ra6e65n9nj2augs760

Interesting. I'll have to have a look if it's a reasonable time.

There must be books surfacing soon on the topics of Swift and app development too - I'll be looking out for this too.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Sun Nov 30, 2014 8:26 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Fogmeister wrote:
Also, something to blow your mind. You can now do things like put the clockView into a collection view or table so the user can pick from the configurations by seeing them in action :-)


Giving this a go. I've been looking up collection views, and I have one that displays when you tap on a button. The cell view has a UIView and another button in it - the idea is to get the ClockView to draw in the UIView. Not too sure quite how to do this - all the tutorials I've found about these things are assuming that you already know - they seem to involve dropping images in. I'll have to do some more reading about these things.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Mon Dec 01, 2014 7:12 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Right - I think I’m getting there, but I’ve hit a snag - or rather a crash. My current goal is to make something based on a UICollectionView appear - even if it’s static images!

I think it may be down to me not connecting outlets properly, but xCode seems not to have made the connection. Usually there’s a little filled in grey dot:
Image
So this one is good - the outlets have been connected properly.

However, in my ClockSelector.swift file, the dot isn’t filled in:
Image
Now, this is odd as the connections are shown as being made in the Inspector:
Image
And I can set them up in Interface Builder:
Image

From what I have been reading, the crash I am experiencing can be down to disconnected outlets, so I am guessing that this is where the problem lies. So, if I can get those outlets to connect properly, then I should be OK.

To outline what I have - I have two panels in Interface Builder:

1 - The main clock
and
2 - The view controller. When you tap on a button, the second pane should pop up. It’s at this point where the crash occurs.
ImageClick for large view - Uploaded with Skitch

The crash looks like this (not seen this output before)
ImageClick for large view - Uploaded with Skitch

Not sure what “Swift Dynamic Cast Fails” means yet - my next port of call on Google.

The problem I have is that all the tutorials I read tell you how to set up a CollectionView as the first thing you come across - either as a gallery app type demo, or as a plain demo with nothing else. I’m trying to get a collection to display when a button is tapped.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Tue Dec 02, 2014 11:22 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Hmm...

Well first off your segues are a little messed up. You should only ever have segues in one direction.

It's quite hard to see what's going on here.

If you're online later I can have a look with you on a Google Hangout if you want?

Might even be able to get some remote help stuff going.

Better that way than me just editing stuff I think. Then you can see what I'm doing and why.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Tue Dec 02, 2014 4:22 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Fogmeister wrote:
Hmm...

Well first off your segues are a little messed up. You should only ever have segues in one direction.

It's quite hard to see what's going on here.

If you're online later I can have a look with you on a Google Hangout if you want?

Might even be able to get some remote help stuff going.

Better that way than me just editing stuff I think. Then you can see what I'm doing and why.

I could give that a go - give me a shout when you're around. Ping me in FB messenger or something. I've not been well, the last few days (chest infection), so best not leave it too late.

I've been trying to follow advice from various sites, which is why the segues are as they as - it was a solution suggested on StackOverflow. I'm assuming that people there know more than I do (and it seems to be the only way to return).

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Tue Dec 02, 2014 5:00 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Just to follow up from my last couple of posts - Oli and I had an interesting couple of hours on Google Hangouts last night looking at the clock app. The result of the evening was that there is a really nice looking clock selection pane which looks like this:

ImageClick for large view - Uploaded with Skitch

Each of the clocks in that pane are live - they sue the same object that the main display uses, but presents them in what could be a scrollable selection. Tapping on the face of choice loads that into the main clock display. The beauty of all this is that I can define a new clock face, add it to a list and it all just happens. I’m somewhat relieved to say that I wasn’t too far from what was needed to achieve this, but it always helps to have someone more knowledgeable take a look and offer advice. Interestingly, it seems to involve a lot less code than I was led to believe by the examples I’d been looking at on line. So, thanks to Oli for that. 8-) :D

Oh - the fourth face is me experimenting with something. I’ve just found that I can clip sub layers to the UIView (I may switch to masking, but this answers an immediate question so I’ll stick with the self.clipsToBounds = true for now), so I’m having a bit of a play with that. A couple of ideas spring to mind. It relies on me finding just the right font, though.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Wed Dec 03, 2014 10:26 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Just to show you what can happen when people don't know what they're doing...

Image

That's a single ViewController file. :(

In a project I may be taking on. :cry:

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Dec 03, 2014 9:08 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Fogmeister wrote:
Just to show you what can happen when people don't know what they're doing...

Image

That's a single ViewController file. :(

In a project I may be taking on. :cry:

That's a lot of things to show!

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Wed Dec 03, 2014 9:40 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Woo - persistence!

Today (and I am sure Oli will be pleased to learn this), I managed to get the app to save the clock face so that when it returns, it’s the same one as previously selected. It’s saving the index number of the configuration in the array and reading it back when the app starts. I thought this would be a useful feature to add, as well as being helpful for me when testing newly added faces. I had to re-jig a protocol so that data sent back to the delegate bit accepted not only the configuration to display, but also the index of that configuration.

Also, as promised, a new clock face to enjoy.
ImageClick for large view - Uploaded with Skitch

This one is still a clock - there are three hands, but this time, two of the hands are actually discs with the numbers on. They rotate, showing the right number in the window. I have a watch like this, and it’s bloody insane to tell the time on. I thought that something similar would work nicely in this context. :lol:

So that’s four faces to date, an easy way to change faces, and that state is saved so when the app is relaunched, the last chosen face is displayed. I’m dead pleased with this. I may have to try a Mac app as well (I have an idea for that - but I need to rough out specs for it - I also have a question that I’ll ask in another thread).

Things to do:
• I’d love to see this working on an Apple Watch now. The more I do this, the more I feel that it needs to be wrist bound as well. I expect I’ll need to do a “helper/slave” partnership, and use the phone to control what faces is displayed on the watch (I guess you’d send the necessary graphics to the watch as needed).

• Also, do what Oli has suggested and dump hands into arrays, so I can have more than one second hand. In the first face, the day/night thing is actually just another hour hand, and it]s specially catered for. That hard coding needs to be removed. The configuration of everything needs to be in the configuration data, not the engine.

• Chuck it on the App Store. I expect some people may want such a thing in their lives. :lol:

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Thu Dec 04, 2014 3:58 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Oli will be please - I’ve started to work on putting the hands and decorative elements into arrays. I’ve spent quite a bit of time on the hour hands today (this will be my model for the others).

Hour hands are now pushed into an array - so you can have as many as you want. An array of CALayers is created to accommodate them, and ClockView now displays them all correctly. I am aware that I may be creating CALayers as I swap themes - so when I’ve done this, I’m aware that I’ll have to destroy them to stop a build up, or find a way to manage them.

Quite pleased that I’ve done what I’ve done today. :D

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Mon Dec 08, 2014 4:32 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
paulzolo wrote:
Oli will be please - I’ve started to work on putting the hands and decorative elements into arrays. I’ve spent quite a bit of time on the hour hands today (this will be my model for the others).

Hour hands are now pushed into an array - so you can have as many as you want. An array of CALayers is created to accommodate them, and ClockView now displays them all correctly. I am aware that I may be creating CALayers as I swap themes - so when I’ve done this, I’m aware that I’ll have to destroy them to stop a build up, or find a way to manage them.

Quite pleased that I’ve done what I’ve done today. :D

Nice! Yeah, I was going to suggest scrapping all the layers and creating them again when the config changes (it won't change that often so not too worried about performance). :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon Dec 08, 2014 5:46 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Fogmeister wrote:
paulzolo wrote:
Oli will be please - I’ve started to work on putting the hands and decorative elements into arrays. I’ve spent quite a bit of time on the hour hands today (this will be my model for the others).

Hour hands are now pushed into an array - so you can have as many as you want. An array of CALayers is created to accommodate them, and ClockView now displays them all correctly. I am aware that I may be creating CALayers as I swap themes - so when I’ve done this, I’m aware that I’ll have to destroy them to stop a build up, or find a way to manage them.

Quite pleased that I’ve done what I’ve done today. :D

Nice! Yeah, I was going to suggest scrapping all the layers and creating them again when the config changes (it won't change that often so not too worried about performance). :D


Done that - so all the layers are now contained in arrays (all the hour hands together, second hands, etc.) and the code now loops though those, drawing them and rotating them as needed. When you change the clock face, it scraps the layers and rebuilds them. This gets rid of the funny “dance” they did as layers are resized and moved around. It looked entertaining at first, but it got annoying.

There’s a couple of niggles in the code that I need to straighten out (I expect that there is some duplication of functions going on), and possibly a question for later if I can’t resolve a problem.

Edit:
Starting to chip away at the code. I’m realising now that hands and decoration elements are the same - graphical objects - and as such they only become hands if I put them in a “hands” array, and they only become decorations if they go in the “decorations” array. At that point, the ClockView object knows what to do with them.

The fly in the ointment is that some decorations MAY be animated (ie they may be visible cogs rotating in the background, for example), and they need to be handled differently to hands.

So I’m having a bit of a think about this - but I may be stripping more code out as things start to sink in a little more. A lot has gone (or been commented out) today as I’ve worked through putting things in arrays. More will go, I expect, as I work through this.

After that, the question which I won’t ask yet because it will probably distract me.

Right now, though, everything is now in an array depending on its function.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Tue Dec 09, 2014 10:46 am
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
A bit of fun. I’ve set it up now so that decoration layers rotate - they just spin dumbly. There are start and end angles, as well as a duration. The result is (for now) that I can have gigs in the background seemingly “working” the mechanism. Eventually, I’ll add in oscillation, so some elements move back and forth, a bit like a pendulum would.

For now, though, this hideous image shows what I have:
ImageClick for large view - Uploaded with Skitch

Outer cog rotates clockwise once every 30 seconds, the inner one rotates anticlockwise every 20 seconds. I’m rather pleased with this, and because I spent some time lumping elements into arrays, I’ve had to do very little to get this working. :D

OK, so next step is to make a clock face that has guts - that is some inner workings that are behind the face and hands. Wish me luck.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Thu Dec 11, 2014 9:54 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 79 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

Who is online

Users browsing this forum: No registered users and 93 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.