views:

537

answers:

1

I'm using the new in-app SMS features in my iPhone app, but obviously iPod Touches aren't able to send and receive SMS without support of a third party app.

I know all well how to detect the device and how to hide a UIButton, but what I do not know is how to change the width of the others.alt text

Above are the three icons. The one on the far rights needs to be hidden on an iPod Touch, and the other two need to adjust size/ position to fill the remaining space.

Any tips on programatically changing the position and width of a UIButton is greatly appreciated. Thanks!

A: 

Take a look at Erica Sadun's UIDevice extension framework: http://github.com/erica/uidevice-extension

You can use this library to detect the device type, then change the frame of the UIButton based on device type.

Example:

NSRange *range = [ [ UIDevice platform ] rangeOfString: @"iPod" ];
if( range.location != NSNotFound ) {
   lastButton.hidden = YES;
   CGRect newFrame = CGRectMake( ... );
   firstButton.frame = newFrame;
   secondButton.frame = newFrame;
}
Jacob Relkin