If you haven’t seen Get Socialize yet, check them out now at http://www.getsocialize.com! I’ve been implementing their SDK into a new iPad application I’m building and their SDK is great. I had to completely rewrite some of the UI methods to build it out for the iPad properly, but even still this software has a lot of potential.
How to create Pulse style scrolling with a Horizontal UITableView (Including Bounce!!)
Alright, this is actually really simple.
You would think this would work
Create your main UITableView – then in each cell create another UITableView and apply a transform of 90° and you’re good. But UITableView’s don’t work like that – you end up losing bouncing horizontally on your internal UITableView’s and there is seemingly no solution, but it’s easy.
Wrap your Cell’s UITableView in a UIScrollView. – [scrollView addSubview:tableView]
Bouncing will work now. (I use EasyTableView - https://github.com/alekseyn/EasyTableView)
Corrupt .png iPhone causes black and white stripes
Today I built an iPhone app in simulator and it looked great, but on the actual iPhone the images were just black and white stripes across the screen. I couldn’t find what caused the error but it seems certain .png’s aren’t liked by the iPhone, perhaps getting corrupted. I resaved as a new .png and now the images look great!
fatal: Unable to create ‘/Users/brandoncopley/Documents/Capabilities/.git/index.lock’:
Error:
I’ve been seeing this error a lot lately in XCode.
fatal: Unable to create '/Users/brandoncopley/Documents/Capabilities/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
In order to fix it, run this in terminal:
rm /Users/brandoncopley/Documents/Capabilities/.git/index.lock
There we go, all good now! (Change the directory there to whatever directory the error is showing up in for you)
GDataXML Leaks
I’ve started using GDataXML for almost all of my iPhone XML needs, but I quickly noticed that after a few refreshes my project was leaking thousands of strings and this was unacceptable. Almost 1MB of leaked strings after 5 refreshes. To curb this, write this wrap your GDataXML code in a NSAutoReleasePool block (you might have to change some NSAutoReleasePools to blocks within the GData code as well)
NSMutableArray* posts = [[NSMutableArray alloc] init];
@autoreleasepool {
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:responseData options:0 error:nil];
NSArray *documentArray = [doc.rootElement elementsForName:@"Comic"];
for (GDataXMLElement *element in documentArray) {
//Do something...
NewPost* post = [[NewPost alloc] init];
//Set post up...
[posts addObject:post];
[post release],post=nil;
}
[doc release],doc=nil;
}
//_posts is a NSArray instance variable, setting it to nil before setting it releases all of the objects in it.
_posts = nil;
_posts = posts;
UIPopoverBackgroundView
With iOS5 a number of new features abound for us programmers including the ability to easily subclass and restyle the standard UI functions. I spent some time today and learned how to style a UIPopoverController and it took a bit of work because the documentation seemed incomplete to me *EDIT* This is because you HAVE to include the correct header file*EDIT* so here is my solution.
When you create your popoverviewcontroller You must set it’s popoverBackgroundViewClass to your own custom class as such:
popoverController.popoverBackgroundViewClass = [CustomPopoverBackgroundView class];
}
Then your subclass CustomPopoverBackgroundView must conform to a couple of classes, and include a custom drawn image for the new UIPopoverController Background. I have added a UIImageView just for that. So your .h file looks like this:
#import <UIKit/UIKit.h>#import <UIKit/UIPopoverBackgroundView.h> UIKIT_CLASS_AVAILABLE(5_0)
@interface ComicPopoverBackgroundView : UIPopoverBackgroundView {
UIImageView *_imageView;
}/* The arrow offset represents how far from the center of the view the center of the arrow should appear. For `UIPopoverArrowDirectionUp` and `UIPopoverArrowDirectionDown`, this is a left-to-right offset; negative is to the left. For `UIPopoverArrowDirectionLeft` and `UIPopoverArrowDirectionRight`, this is a top-to-bottom offset; negative to toward the top.This method is called inside an animation block managed by the `UIPopoverController`.*/
@property (nonatomic, readwrite) CGFloat arrowOffset;
/* `arrowDirection` manages which direction the popover arrow is pointing. You may be required to change the direction of the arrow while the popover is still visible on-screen.
*/
@property (nonatomic, readwrite) UIPopoverArrowDirection arrowDirection;
/* These methods must be overridden and the values they return may not be changed during use of the `UIPopoverBackgroundView`. `arrowHeight` represents the height of the arrow in points from its base to its tip. `arrowBase` represents the the length of the base of the arrow’s triangle in points. `contentViewInset` describes the distance between each edge of the background view and the corresponding edge of its content view (i.e. if it were strictly a rectangle). `arrowHeight` and `arrowBase` are also used for the drawing of the standard popover shadow.
*/
+ (CGFloat)arrowHeight;
+ (CGFloat)arrowBase;
+ (UIEdgeInsets)contentViewInsets;
@end
Then in your .m file:
#import "ComicPopoverBackgroundView.h"@implementation ComicPopoverBackgroundView@synthesize arrowOffset, arrowDirection;-(id)initWithFrame:(CGRect)frame{if (self = [super initWithFrame:frame]) {
UIImageView *_imageView = [[[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"UIPopoverControllerBackground.png"] stretchableImageWithLeftCapWidth:50.0 topCapHeight:380.0]];
[self addSubview:_imageView] autorelease];
}
return self;
}-(void)layoutSubviews{
_imageView.frame = CGRectMake(0, 0, self.superview.frame.size.width+10, self.superview.frame.size.height+10);
}
+(UIEdgeInsets)contentViewInsets{
return UIEdgeInsetsMake(0, 10, 0, 0);
}
+(CGFloat)arrowHeight{
return 30.0;
}
+(CGFloat)arrowBase{
return 42.0;
}
@end
The only issue I have so far is that in the _contentViewFrame method I am needing 602 and 600 which is the width and height of my popovercontroller. I am sure there is a way to access that dynamically I just haven’t looked into that yet. EDIT* You can set this dynamically if you take UIEdgeInsets and ArrowHeight into account.
The important part is to implement the -(CGRect)_contentViewFrame; method which the documentation does not mention so I was repeatedly getting this error:
-[CustomPopoverBackgroundView _contentViewFrame]: unrecognized selector sent to instance 0xc547b80
EDIT* if you import: #import
You can then subclass UIPopoverBackgroundView properly rather than UIView and remove the nasty _contentViewFrame view.
Code has been updated to reflect these changes
How to create a basic html based Windows 7 gadget
So how do you create a basic windows 7 gadget? I have begun building an html based Windows 7 gadget in order to design a touchscreen gui for Windows 7 but here are the basics of an html based gadget.
Simple.gadget (folder)
index.html
gadget.xml
logo.png
1. Create a directory and name it Simple.gadget, feel free to rename it as long as the file appears as such : *.gadget
2. Create your index.html (here is a basic html file, but this is your interface, so feel free to go crazy, use css, javascript, etc. – gadgets are basically websites running on your desktop)
<head>
<title>Simple Gadget</title>
</head>
<body style="width:200px; height:200px;">
<p>Hello World</p>
</body>
</html>
3. Create a cool logo! something simple maybe? Here I’ll use this:
4. Create your gadget.xml folder
You’ll need 3 things here: your html file name/location, your gadgets name, and any other side information you want to add in – there is a lot you can do with this file, but this is just a simple gadget.
This folder will contain the following code:
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
<name>simple</name>
<version>1.0.0.0</version>
<author name="Brandon Copley">
<info url="www.brandoncopley.com" />
<logo src="logo.png"/>
</author>
<copyright>© Your Name.</copyright>
<description>This is a simple gadget.</description>
<hosts>
<host name="sidebar">
<base type="HTML" apiVersion="1.0.0" src="index.html" />
<permissions>Full</permissions>
<platform minPlatformVersion="1.0" />
</host>
</hosts>
</gadget>
And there you have it a simple html based Windows 7 gadget. There are two things to watch out for. NAMING CONVENTIONS!!! your gadget.xml file MUST be called gadget.xml, feel free to name index.html whatever you want – I even use .hta’s in order for the file to be able to access the windows file system – more on that later. Also your gadget name in the xml file must be the same name used as your folder name so if you want to name your gadget “cookbook” you must change the folder to cookbook.gadget also.
Installing your gadget
In order to install your gadget you must take note of 2 things.
1. As you develop your gadget you don’t have to install it, you can simply drag your simple.gadget folder over to the C:\Program Files\Windows Sidebar\Gadgets folder with all of the other gadgets.
2. When you actually go to install your gadget you must take your simple.gadget folder and compress it to a zip file.
simple.gadget.zip
The next step is removing the “.zip” from the folder title and then you can go ahead and double click to install the gadget.
It’s that simple.
NOTE: If you are running windows 64bit you CANNOT run flash files from your .html, why? because there is NO 64 bit version of flash yet therefore you must close out of all of your gadgets, run C:\Program Files (x86)\Windows Sidebar\sidebar.exe and then install your gadget to that Gadget folder.
So there ya go – how to create a basic html based Windows 7 gadget.
Source Files: simple.Gadget.zip
Fixing an iPhone 2g power button
So my iPhone’s power button broke a couple of weeks ago and the button was permanently stuck in a state of depression (haha). I could jostle it free but it frequently would just start turning itself off and then back on since you turn the phone on by holding down the power button and turn it off by holding the power button. So although I got a new iPhone 3gs I decided to see if I could repair my old iPhone and here are some pictures from that process.
The iPhone before I began. Look at how nice of condition this phone is still in (the bubbles on the screen are from the screen protector, the screen is immaculate). It’s a 2g but only a year old and what happened was I had it sitting on the conference table at work and someone knocked the phone off the table and it landed on the power button on the carpet thus permanently depressing the switch.
And here is the phone with the plastic casing off. This was one of the hardest parts and I never could get the plastic back on perfectly but since the phone is in a hardshell inCase case the slight bend in the black plastic can’t be seen.
So here is where I removed 3 screws holding the metal cover on the phone. The screws were quite small and I had to use an exacto knife to take them out but this was easy compared to actually removing the cover.
This step took the most patience as I pried the metal cover off of the phone. As I was removing the cover it felt like I was about to damage the phone and although I slightly bent the metal cover (about 1/4mm – on one side, not noticeable) I finally got it off without too much hassle. I just had to take that long black tool in the upper left and shove into the phone and then pry the cover off with quite a bit of force.
And this is the BUTTON! What you can see here is the plastic power button and the membrane covering the actual switch. After removing this I couldn’t see anything wrong but after bending the metal a bit and then fitting the button back into place the button works. It’s not working like a new button though and has no movement when pressed, so you just kind of set your finger firmly on the button to press it.
So that’s about it in what I did to fix this phone. It’s working great and it’s a nicer condition phone then the one Kayle had so I gave it to her and now I have her old phone over here ready for me to play with : ). Her phone has a major problem with the known mechanical issue of the iPhone thinking the headphones are plugged in. This is fixed by repeatedly inserting/removing the headphones forcefully, but this can get really annoying. Her old phone was also extremely quiet but I can’t figure that out – some speaker issue.
Brandon Copley
Grad School at The University of North Texas

Well so far I have begun my life as a grad student up here at the University of North Texas. I am studying Electrical Engineering and have a challenging 9 hours of grad course work this semester which is full-time and I am also working full time for a company called CBS ArcSafe. It’s an interesting position and I’m getting the opportunity to learn about the company and work on some new projects.

It’s also been great being up here because I am able to spend quite a bit of time with my girlfriend, Kayle. We have a lot of fun being near each other up here and we frequently cook meals together and hang out as much as school/work allows. It’s not much time but it’s some.
I regularly study back at my apt with my friend Khurram who is from Pakistan and I have a number of other friends from the Middle East, specifically India seems to be the place to be from but it’s cool getting to spend time with these guys as their culture is so much closer to Thailand’s than America’s and I can understand the difficulties they have as students in America, not only being away from family but also not being as wealthy as they are over in the Middle East. America is expensive!!
Well life is good and UNT is great fun, hopefully soon I can write again and maybe start writing some recipes. Kayle and I do a lot of cooking and we have been creating some cool recipes…nothing too crazy but we have been finding some easy cooking techniques that make some great quick meals.
Sharing is caring and why iPod’s are selfish
Throughout my backpacking adventures in Southeast Asia I have learned many things but the one thing that sticks with me is how people love to share over here. I forget in America how selfish we are, we just don’t share enough. So I think that I am going to start sharing in the same abundant ways that some of the people I’ve met over here share.
I have seen many different examples of people sharing throughout my travels but one way that has stuck with me is how often you share your food when you go out to eat. At a restaurant a common practice in America is for the waiters to bring out all of the food at the same time, but that is not the case over here. Rather than bring out your tables food at the same time it is more common for dishes to br brought out at different times sometimes as much as 15 minutes apart. This seems to be very common and it really helps promote sharing among groups because one person has their food and thus shares with the group while the rest of the group waits until their plate arrives. This even happens at coffee shops when things like deserts are brought out as much as 5-10 minutes apart even when they are ordered at the same time. Why we don’t do this in America astounds me because food is meant to be shared and what better way to share than have one person feel so awkard sitting there for a few minutes with food in front of them while no one else has food. This helps promote sharing of the food when you are hungry and overall is a great system.
Last night I also experienced a great concept of sharing as I am on a 24 hour bus ride to Hanoi from Vientiane as people shared their music with the bus. See these busses don’t have radios and from an American view I had not realized that using headphones on your mp3 player is selfish. Just because I am fortunate enough to have an mp3 player doesn’t mean that I should be the only one who listens to my music. In Southeast Asia this seems to be common knowledge that those with mp3 players should share their music with others. This made my night much more enjoyable as about 3 people on the bus had their cell phone mp3 players playing different kinds of music for the bus to listen to. This meant that as a listener I wasn’t tied down to one person’s music I got to selectively choose which speakers to zone in on and try to zone the other ones out as I lay awake on the bus all night when I couldn’t sleep. You see I have a hard time sleeping when there is annoying noise playing in the background, but these little cell phone speakers are constantly improving and getting the chance to listen to the award winning Thai pop really made my night pass by faster than sleeping would have.
Another common item people share over here and people share these in America too are cigarettes. However in Austin we have banned smoking inside any of our buildings and it is disappointing because we have the opportunity to share and instead choose to be selfish. It seems common that in and around large groups for smokers to help out those people who haven’t bought cigarette’s to share their smoke so it can be like those people are smoking. This means I constantly get to share in these peoples smoke as they help me out by blowing it not even away from me but right in my face. I never thought I would have appreciated this, but it seems to help me out because I get all the effects of smoking without ever having to spend my money on cigarette’s. Although this isn’t common to just Southeast Asia most people in America have stopped sharing their smoke with others because we are a selfish people group, we talk loudly, we complain, we argue and we don’t help those less fortunate by helping those who haven’t brought their cigarette’s along for the ride by blowing smoke in their face for them to smoke too.
These lessons from Southeast Asia have really opened my eyes to the selfishness of some people and I really think this has got to stop. More than anything as a people group if American’s really wants to be successful at being honest and caring we must start taking up these habits of sharing our food, music, and smoke with those who are less fortunate than ourselves.

