Skip navigation

Category Archives: Issues

I had a UIImageView control set up in one of my Views using Interface Builder, but I wanted to resize the UIImageView control programmatically depending on the device’s screen size.  I spent several hours trying all sorts of techniques, but I always had problems.  If I resized the UIImageView’s frame in viewDidLoad, it simply wouldn’t work.  If I resized its frame in viewDidAppear, it would work but the user would see the original-sized image before switching to the updated size which I felt was ugly and unnecessary.

I finally found a solution that would show the correctly resized UIImageView right away, but it required me to remove the UIImageView from my .XIB file, remove the outlet from Interface Builder, and remove the IBOutlet from my header file.  Then I simply programmatically added the UIImageView to the view in my viewDidLoad like so:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 173, 728, 771)];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.image = [UIImage imageNamed:@"tutorial1.png"];
[self.view addSubview:imageView];

I was recently at wit’s end with what seemed like it should be a non-issue: I had taken a screenshot of my iPhone, cropped the image down to a single button, and was then trying to display it as the background image on a UIButton. The problem was that the image would appear twice as large. After stepping through the code, I realized that the UIImage object had a scale value of 1.0f instead of 2.0f like it should (I have an iPhone 5 with Retina Display). After some snooping around in Apple’s UIImage reference, I realized the fix was simple: I just had to add “@2x” to my image’s filename.  BUT there is one caveat:  when referencing the image’s filename in your code, do NOT add the “@2x”.

For example, if your image filename is “HelpIcon@2x.png”:

INCORRECT (image has scale factor of 1.0f and is too large)

[button setBackgroundImage: [UIImage imageNamed:@"HelpIcon@2x.png"] forState:UIControlStateNormal];

CORRECT (image has scale factor of 2.0f)

[button setBackgroundImage: [UIImage imageNamed:@"HelpIcon.png"] forState:UIControlStateNormal];

Okay, so this isn’t really an iPhone development issue per se, but it was driving me crazy nonetheless.  When I get into my car, my iPhone automatically connects to the car’s Bluetooth and all calls/music play through the car’s speakers.  This is great except for text message alerts:  since they’re so short, apparently the delay opening the Bluetooth link causes them to basically not get played at all.  Now I could disable Bluetooth completely on my phone but that seems like overkill, and I like the hands-free calling experience it provides.  What I needed was a quick way to toggle the iPhone’s speaker connection from my car to itself, and I finally found it! Read More »

After finally submitting my first app to Apple’s App Store, I figured I should pass on some helpful tips that I learned during the process.

  1. If you have an idea for an app, go ahead and create the application in iTunes Connect now.  You will have to upload some images for icons and screenshots, but those can be changed later.  You won’t have to submit your app’s binary yet.  Why go through all of this trouble so early on?  Because it prevents any other developers from taking your app’s name! Read More »

I was trying to make an iPhone app that performed what I thought was a simple task:  seamlessly transitioning from the default image displayed when the app was opened (Default.png) into a fullscreen UIImageView that showed the exact same image.  Unfortunately I kept running into alignment problems where one image seemed to be displaced by 20 pixels (40 pixels on retina displays), and initially I couldn’t even tell whether it was the default image or ensuing UIImageView image that was offset.  I eventually figured out that it was the UIImageView image that was the problem, but determining why was a bit trickier. Read More »

I recently updated my Macbook Pro to Mountain Lion and then downloaded and installed Xcode 4.5.2.  I still had Xcode 3.2.6 installed as well, and my goal was to update my existing projects to the newer version.  Unfortunately when I tried to load my first project, Xcode just hung and sat there loading forever until I Force Quit it.  I soon realized that this same issue occurred even if I tried to create a new project, tried to open the Repositories tab in Organizer, or even if I hovered over Xcode’s File -> Source Control menu item.  My system log continuously showed the same error:

Nov 12 14:14:50 MacBook-Pro.local Xcode[3307]: [MT] DVTAssertions: Warning in /SourceCache/IDEFoundation/IDEFoundation-1880/Framework/Classes/Model/SourceControl/IDESourceControlTree.m:130
Details: Invalid location for source tree. Initialization failed: {
IDESourceControlRepositoryLocationKey = "";
authenticated = NO;
name = iPhone;
online = YES;
path = "";
system = "scm.subversion";
}
Object:
Method: -initWithDictionary:sourceControlExtension:sourceControlManager:
Thread: {name = (null), num = 1}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. Read More »

I was having a heck of a time getting pretty permalinks to work with this site.  I figured it had to do with setting up WordPress in its own directory, which I had done using their own instructions (http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory). In the end it turned out I was right.  My .htaccess file that I copied into my root web directory looked good, but I needed to turn on Apache’s AllowOverride setting.  After some snooping around on my Ubuntu 12.04 machine, I finally discovered where to make this change.  In the /etc/apache2/sites-available directory, I had to update the file called default.  There was a configuration section in it for the /var/www directory and changing “AllowOverride None” to “AllowOverride All” did the trick!

After installing WordPress on my Ubuntu 12.04 server (and seeing that it was successfully working), I tried to move WordPress into Apache’s root directory (/var/www) using the instructions found in the pre-existing subdirectory section here (http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory).  Unfortunately no matter what I did, trying to hit both http://tripletwollc.com and http://tripletwollc.com/index.php only resulted in my browser trying to download the index.php file instead of displaying it.  I spent several hours mucking around with caches, config files, and the kitchen sink before finding out that the solution was, in my case, maddeningly simple. Read More »