iOS today view widgets and margins

One of the toughest things I’ve had to deal with while working on an app has been the today view widget. The widget I’ve been working on is very simple: 2 buttons and a label. Yet, there were a couple of issues I kept running into.

  1. When loading the widget, my buttons will appear and layout. With a button tap, the two buttons change size to what is constrained in the Storyboard. This only happens when the widget is loaded and with the first tap. Subsequent taps don’t affect it again.
  2. The widget, as much as I tried, would not appear as it did in the storyboard. Things weren’t centered properly.

The first item I still haven’t solved. The issue that ended up solving the second item is what I thought was affecting the button layout. Essentially, here is what I had: left button is x points from the left edge of the view, is y points from the right button, and has a width equal to the right button. The right button is the same except it has a constraint to the right edge of the view instead of the left. I had hoped that this would lead to a dynamic button size that would change on various devices and widths. Unfortunately, the small issue with the resizing buttons kept bothering me. If someone can figure this out, let me know.

The second issue was actually fairly easy to figure out. If you look at any of your current widgets, you probably notice two different layouts: ones that are full width, and ones that start indented.

I thought that Apple wanted all widgets indented, but there are even some of Apple’s own widgets that are full width. While it wouldn’t solve the first issue I was having (and gave up on), it did impact why the storyboard, set to the width of the device, wasn’t looking like what my widget was showing.

To solve this, make use of the NCWidgetProviding protocol. There is a method called widgetMarginInsetsForProposedMarginInsets  that you can use to either accept the default margin or set it to a custom value.

By removing the insets, I suddenly had a widget that not only was centered but also was taking up the space in the view as it was in the Storyboard.

If you want to see what I was working on, check out Countr on the App Store.

The advantage of digital work

I’ve had JoshsPadd.com for over 10 years. This WordPress site has been up for over six. Yet, I always felt like I wasn’t writing as much as I wanted to.

The very thought of writing can be intimating when you feel you have a lot you want to say. For instance, I recently completed our birth story post. I had started on it shortly after the birth of our son. But as time went on, it kept getting put off. The idea of being thorough with what I was writing held me off from just sitting down and finishing it. Would I miss something vital? Would people like what I had completed?

That last thought is something that I also struggle with when I’m developing apps. Sometimes I get so caught up in making things just right that I don’t release an update as quickly as I could. But sometimes, you just need to sit down and go through with something and deal with any missed details later.

The advantage of digital work: it can always be touched up.

 

Countr, my first app on the App Store

It’s been many months since I last talked about app development. I’m a bit disappointed with myself, personally, and how much I haven’t shared. It’s been a fun experience as I’ve dived into Objective-C, Xcode, and learning how to develop things on my own. Since then, iOS 8 was previewed (and since launched), Swift was introduced as a new programming language, and more APIs and development tool updates have happened across the Apple ecosystem.

Well, I’ll be writing more thoughts about the development process soon. But first, I wanted to talk about the first app I’ve developed through to launch. That is Countr, a simple app to quickly take a count. I had wanted an app to help me take a count when I’m at certain meetings or assemblies. I feel this app does this excellently.

While the app was released in late August, I only just now announced it. Moving to Arizona took up a lot of time. Go figure.

Countr not only helped me learn the development process, but I got a nice overview of the app release process. I’m very grateful for the update to iTunesConnect, which has made it a much more attractive experience when checking on the status of my app.

In upcoming posts, I’ll talk about developing Countr, developing for iOS in general, and some other things that I thought were pretty cool.

I want to thank the few friends that helped beta test Countr before release. I got a lot of good feedback and, while it is a simple app, the others that I’m working on are not as simple. I made sure to use the same process with Countr that I would expect with a larger, complex application. It’s been insightful, and I’m ready to release more apps later this year.

Countr is available for free on the App Store.

My Adventures In App Development (Part 1: The Beginning)

I hate saying that I’m relatively new to app development, but I am. I had originally moved into the Apple ecosystem in 2009 with somewhat of a desire to develop applications. At the time, however, I was spending most of my development time on websites. App development seemed like a much more daunting task.

Over the years, I would occasionally open up Xcode with the intent of creating some kind of basic iPhone app. Each time, though, it seemed like such a different beast than what I was used to. (The MVC model wasn’t a stranger to me, but I didn’t have a lot of experience with it at the time.) I’d add in a few buttons and views, type up some code, but I couldn’t get myself to really dive into it.

One thing I’ve come to really love using since I first got my first iPhone in 2009 is Evernote. I use it to store notes about almost anything, from guitar tab to food recipes. For a while now, I’ve also stored different ideas that come into my head. As I put more and more ideas down in writing, I was able to get a better idea of what I wanted to do.

Two breakthroughs helped me to really push forward in app development, however. The first was making use of video tutorials online, especially on iTunes U, that helped me to really learn and understand Objective-C and iOS app development. Finding an iOS development course is a big plus, as it is just like being in a class where you are taught how to develop for the iPhone and iPad. It definitely beats just reading documentation and following along in a book.

Second was the latest iOS release, iOS 7. As soon as I saw the new look and feel of iOS unveiled at WWDC, as well as reading about the new APIs built into the release, I became excited for development again. In fact, I hadn’t felt this excited about it before.

It was with iOS 7 that my interest was aflame again. Since June, I’ve been pushing forward and working on several ideas. I’ve not been so excited about iPhone app development as I am now. I have a few projects on the burners and, as they get closer to release, I’ll start sharing some information about them, either here or via my business site (which will be updated soon). I’ll also document my travels as I learn more about Objective-C, Xcode, and developing for the iPhone, iPad, and Mac.

[C#] Using Nini .NET Configuration Library

When developing a desktop application, there will be times when you want to store settings for your program. A database is one option, but on Windows, you might just wish to have your settings stored in an INI file. One way to work with an INI file in C# is with the Nini Library. This makes it quite easy to read from and write to an INI file.

Let’s get started.

After installing the library, we’ll need to set our namespace.

What will our INI file look like? Something like this:

For my application, I decided to make a class devoted to the configuration file. So, let’s define that and a few other variables.

Now that we have our variables declared, let’s create a couple of useful methods.

These two methods will update the INI file with new settings, should we change them in our program. Of course, if we make these changes, they need to be saved. Thankfully, we can declare something in our constructor (which we will write a little later) that will auto-save our changes as we make them.

Now, let’s create a pair of methods to return the data. This will be useful in our program when we need to use these settings.

With these methods, we now have a basic class for handling a configuration file. All that is left is our constructor.

But before we get to the constructor, there is something else I created. What if our INI file doesn’t exist? I decided that I would make a function to create a default INI file, should the old one not exist anymore. This is also useful if we want to distribute our program without an INI file.

We can do a check when we initialize our class that will check to see whether or not this file exists. If not, we’ll create it so we can work with it.

That makes this our constructor:

Our whole class thus looks like this:

That’s how simple it can be to work with your own INI files in C#.

Did you find this useful? Let me know in the comments!

Working with DataTable in C#

One thing I’ve had to do lately is learn some C#. I will admit that it isn’t the language I would prefer to work with during the week, but it does help me become more versatile when it comes to application development.

Working with C#, I had to take data and enter it into a data grid. Being that I still consider myself a C# newbie, I figured this was something I might as well learn to use.

In the end, creating a data table in C# isn’t that difficult. In this example, I’ll be taking data from a Microsoft Access database and entering it into a DataTable object.

First, let’s define our DataTable and its columns.

Now, while it isn’t necessary, I like having temporary variables to hold data from a database before entering it into our table. For what we have, that would be:

All that is left to get is the data itself. Assuming we’re getting it from some kind of database, we can get the information in a while loop and add all of the data into the table.

Now we have our data in the DataTable. All that is left is to output it. For this, I have a DataGridView object in my form called myDataGrid.

And that’s all there is to using a DataTable in C#.

Have you worked with DataTables? Submit your experiences and comments below!

My Blog in Review: 2009

Well, the end of the year is here already. I thought I’d look back at what I had on my blog, talk about what is to come, and a little bit of other stuff.

It’s hard to believe that this new blog (code named Jerenspeak) went up back in April. Since then, I’ve covered a variety of topics, from a browser comparison, domain slamming, and Eric Clapton, to Twitter, Star Trek Online, and Doctor Who. It’s been an interesting year, with a range of subjects that I hope my (limited number of) readers have enjoyed.

I do have quite a bit to post on the same subjects. Articles are already written. However, they will be posted more regularly than before, especially after I get my entire site redesigned.

So, what is there to look forward to? More Twitter/online safety tips, Doctor Who news and reviews, information about Star Trek Online, web design/programming tips and guidelines, music/guitar information… it’s all coming! Just be sure to subscribe to my RSS feed or Twitter account to stay on top of it.

I hope everyone stays safe tonight. And we’ll see what comes with my site for 2010!

Google Announce Google Chrome OS

In what seems like another big announcement today, Google has announced that they are working on a new operating system.  The Google Chrome OS is said to be different from Android and targeted towards netbooks.

It is little wonder that this new OS is targeted towards people that want to get online fast.  In fact, their blog post mentions the intention of the OS itself:

Speed, simplicity and security are the key aspects of Google Chrome OS. We’re designing the OS to be fast and lightweight, to start up and get you onto the web in a few seconds. The user interface is minimal to stay out of your way, and most of the user experience takes place on the web.

For someone that has seemed to do a good job at providing both a great internet search engine and a simple, straight-forward browser, it is no surprise that they are pointing towards the web as the platform for their applications.  And, what applications would one use on a netbook?  Documents? Spreadsheets? Google Docs covers that.  Email? Gmail has that down, too. What about talking with your friends online? Google Talk handles that.

“Alright,” some of you may be saying. “So you’re suggesting that Google does it all?”  Not necessarily.  There are times where you might find a need to chat with friends on Yahoo or MSN quickly, which is where a service such as Meebo can come in.  Or if you need to pop on IRC to get some Ubuntu support, you can use a variety of web-based solutions, including Mibbit.

Overall, this may lead to a very versatile application environment:

For application developers, the web is the platform. All web-based applications will automatically work and new applications can be written using your favorite web technologies.

With the web as your platform, that gives you quite a few options.  And, if we can assume that Google Chrome will be the standard browser in Google Chrome OS, then you’re looking at a fairly stable, smooth operating environment for your applications.  Plus, there’s the added benefit:

And of course, these apps will run not only on Google Chrome OS, but on any standards-based browser on Windows, Mac and Linux thereby giving developers the largest user base of any platform.

If some app happens to stand out on Google Chrome OS, it is possible it either already exists on the web or would be easily available for the rest of us to use (should we not be using Google Chrome OS).

As people use the Internet more and more for work, communcation, and the overall sharing of ideas, simpler and smaller internet solutions may be required.  Netbooks cater to that audience.  And, given how Google Chrome itself has jumped into the browser pool, Google Chrome OS may make a similar splash with netbooks when it is released.

Share your views on this!  Leave a comment or send me a tweet about this post.

New Site Coming

At least, I’d like to think that I have a new site coming.  Well, I have several new sites coming.  But, when it comes to this site, it’s a new design that I’m talking about.

The last couple versions of JoshsPadd have been darker, though I was proud of the last version when I created it years ago.  At least, I was of the design.  I never did get around to really making a site out of it.

Now, I’m going for a brighter look.  Something professional, sleek, and hopefully attractive.  Just like me! (At least, that’s what I think…)

How will the new site look, exactly?  That hasn’t been created yet.  All I do know is that, soon, a new site will be there.  The splash page is a little sample of the kind of look that I’m going for (and borrowed from a splash page I made for another site I recently did).  It hopefully will be something people like.  And if not, then I may have to tweak it a bit (depending on who the people are that I ask).

But if anyone has ideas on how my new site should look, let me know!  This is going to be a my portfolio site, showcasing work I’ve done and being about me and what I do.  So, any ideas to add? I’d love to hear them from you, no matter how you choose to contact me.