These last few weeks I’ve been diving into Apple’s RealityKit for iPhone. I’ve chosen to use SwiftUI instead of UIKit as I like the similarities between it and ReactJS. I thought I’d start posting a few things I learn as I find Apple’s documentation is great if you already know what you’re doing. Unfortunately, if…
Category: Xcode
Subview Rotation on iOS 8 with Swift while keeping static main view
That title is a mouthful. Basically, I just want to know how to imitate the native iPhone camera app. The camera button stays locked where the home screen is but the icons rotate with the device as well as the capture area. Should be pretty simple right? tl;dr: See the code here on github that…
iOS: bounds vs. frames
I got totally hosed this week trying to add a subview to a UITableViewCell. The cool thing is that I learned a lot. I created a custom UITableViewCell that called FeedCommentTableViewCell class. Below is the working code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#import "FeedCommentTableViewCell.h" #import "Settings.h" @implementation FeedCommentTableViewCell - (void)layoutSubviews { [super layoutSubviews]; CGRect labelFrame = CGRectMake(LEFT_PAD, 0, (self.contentView.bounds.size.width - 2 * LEFT_PAD), self.contentView.bounds.size.height); self.commentLabel.frame = labelFrame; } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { _commentLabel = [[STTweetLabel alloc] initWithFrame:CGRectZero]; _commentLabel.font = COMMENT_FONT; _commentLabel.numberOfLines = 0; _commentLabel.lineBreakMode = NSLineBreakByWordWrapping; [self.contentView addSubview:self.commentLabel]; } return self; } @end |
A few lessons learned: 1. initWithStyle is called only when the cell is created and thus will…
iOS icon size generator
One of the things you run into while developing iOS applications is that you need several different icon sizes for the various devices. For an iOS 8 iPhone application, you need at least 4 different sizes: 58pt, 80pt, 120pt, and 180pt. Not to mention the main icon size for the app store. If you develop…
iOS NSStreamDelegates, Grand Central Dispatch, & NSNotificationCenter
One of the more difficult design patterns I’ve managed to get working in Objective-C while developing an iOS app is one that requires NSStreamDelegates, Grand Central Dispatch (GCD) and NSNotificationCenter. This design pattern comes into play in the following situation: Application launches Application does some communication with a server in the background When the server…
iOS app submitted to iTunes Connect
I just submitted my first app to iTunes using Xcode4 and iTunes Connect. There was a bit of a learning curve, but after hacking away at it last night I’m happy to say its sitting in Apple’s queue waiting for review. First off, let me say that even though its a total pain there are…