Home User CP Donate Chat Register Today!  
  Get New posts Faq / Help?
   


Go Back   Hackint0sh > Projects and Hacks > iPhone > Applications & Development > iPhone Developer Exchange

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2008, 07:10 PM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Thumbs up [XCode Template] for SDK and Open Toolchain API in firmware 2.0

This is the latest update of the Xcode template (version 3.5.2) for iPhone SDK and Open Toolchain API / official SDK API (without cert) in pwned iPhone / iPod Touch firmware 2.0.x / 2.1 / 2.2


This Xcode Template is now updated to version 3.5.2

To install, run these in Mac Terminal (assume you have installed the Xcode in /Developer folder, if not, change it according to your installed directory)

Code:
curl -O http://www.iphone.org.hk/attach/42698-ToolChainTemplate_v352.zip
unzip -o 42698-ToolChainTemplate_v352.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"
MD5 (42698-ToolChainTemplate_v352.zip) = 5de15c4cc9f7bab7feeafff5f121da36




There are 4 new project templates to build the command line utility for iPhone
C++ Tool (.cpp)
CoreFoundation Tool (.c)
Foundation Tool (.m)
Objective C++ Tool (.mm)


These 4 command line utility templates used wifi ssh connection to install compiled binary in your iPhone, so you need not connect your iPhone via usb port and MobileInstallation patch is not needed as well.

Requirements & Info:
(1) Default use Open toolchain headers
(2) iPhone and Mac connected to same network (you should change the IPHONE_IP, default is 10.0.2.2 in Project Settings)
(3) Open SSH and Link Indenty Editor installed in iPhone
(4) Mac's ssh key installed in iPhone
(5) Debug / Release build to iPhone folder /private/var/root (no Build & Go) and you should change IPHONE_INSTALL_DIR in the Project Settings
(6) Cannot build to Simulator

You need to amend the IPHONE_IP and IPHONE_INSTALL_DIR user settings twice, one for Release and another for Debug.

If you don't want Open ToolChain headers for these command line tool, just remove the Other CC flags settings in the Project Settings, then it will use the official SDK headers. And you have to remove it twice, one for Release and another one for Debug in Project Settings.

If you need Open ToolChain Headers in your Mac
do this (assume you have installed the Xcode in /Developer folder, if not, change it according to your installed directory)
Code:
      $ sudo mkdir -p /Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/ 
      $ svn co http://iphone-dev.googlecode.com/svn/branches/include-1.2-sdk  
      $ cd include-1.2-sdk 
      $ ./configure --prefix=/Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/ 
      $ sudo sh install-headers.sh

Xcode Template Version 3.5.2 adds a Static Library Template for iPhone
To build the Universary Library for i386 and arm
First build it on "Device" "Release"
Second build it on "Simulator" "Release"
Then the Universary Library binary will be in the project directory
To examine the content of the Universary Library binary, run ./otoolprint.sh in the project folder


Open Tool Chain Application
This template uses open toolchain headers provides a starting point for any application without Interface Builder.

Requirements and Info:
(1) No Interface Builder
(2) Default use open toolchain headers
(3) Cannot build to Simulator
(4) You need to have pwned iPhone / iPod Touch with patched MobileInstallation
(5) You need to have codesign certificate "iPhone Pwned Developer" installed in Mac
(6) You need to have XCode SDK Info.plist Setting removed Provisioning Profile requirement


View-Based Application
This template provides a starting point for an application that uses a single view. It provides a view controller to manage the view, and a nib file that contains the view.

Requirements and Info:
(1) Default use official iPhone SDK headers
(2) You need to have pwned iPhone / iPod Touch with patched MobileInstallation
(3) You need to have codesign certificate "iPhone Pwned Developer" installed in Mac
(4) You need to have XCode SDK Info.plist Setting removed Provisioning Profile requirement

Window-Based Application
This template provides a starting point for any application without Interface Builder and provides a minimal iPhone application with a single view, ready for customizing.
This is a good starting point for your first application. In the UIView subclass, you can implement methods to draw content on the screen and to respond to touches. In a more full-featured application, you typically add a view controller to handle data and to manage rotation.

Requirements and Info:
(1) No Interface Builder
(2) Default use official iPhone SDK headers
(3) You need to have pwned iPhone / iPod Touch with patched MobileInstallation
(4) You need to have codesign certificate "iPhone Pwned Developer" installed in Mac
(5) You need to have XCode SDK Info.plist Setting removed Provisioning Profile requirement


Always reboot iPhone and your Mac after you have changed settings and to troubleshoot

FAQ


If you have "security policy error" after Build & Go. Do these steps

(1) Install a new free app from App Store in iPhone (not sync from iTunes)
(2) Launch that newly purchased free app and then close it.
(3) Reboot your iPhone (that is power off and on again)
(4) Launch the app again that you have Build & Go in Xcode to iPhone.


If you need MobileInstallation Patch (updated to support firmware 2.0 to 2.2)
see post here
http://hackint0sh.org/forum/showpost...3&postcount=14

if you want to know how to remove Provisioning Profile requirement see post #62 below
http://www.hackint0sh.org/forum/show...1&postcount=62

if you want to know how to remove Provisioning Profile requirement for iPhone SDK 2.2 (build 9M2621) see post #125 below
http://www.hackint0sh.org/forum/show...&postcount=125

If you need instruction to have codesign certfifcate "iPhone Pwned Developer" installed in Mac
Here is the nice guide from Apple to create a self-signed identity
http://developer.apple.com/documenta...section_2.html

If you want to know how to install your Mac's ssh key in iPhone
Here it is
In order to avoid typing the password using ssh, you can install the ssh public key of your Mac to your iPhone using the following method

(a) keygen in Mac terminal and type (if you haven't generated it before)
Code:
ssh-keygen -t rsa
(b) create .ssh directory in iPhone (assume ip address of iPhone is 10.0.2.2) and in Mac terminal and type
Code:
ssh root@10.0.2.2 'mkdir -p .ssh'
then enter iPhone root password (alpine)

(c) copy mac public key to iPhone, and in Mac Terminal type
Code:
cat ~/.ssh/id_rsa.pub | ssh root@10.0.2.2 'cat >> .ssh/authorized_keys'
then enter iPhone root password (alpine)

(d) Edit the file /etc/ssh/sshd_config in iPhone

change these
Code:
#StrictModes yes
#PubkeyAuthentication yes 
#AuthorizedKeysFile      .ssh/authorized_keys
to

Code:
 
StrictModes no 
PubkeyAuthentication yes 
AuthorizedKeysFile      .ssh/authorized_keys
(e)reboot iPhone

<---------- add reputation for me if you like this thread
.
.
.
__________________
Touch Dial is an easy-to-use application for one touch dial / sms icon on the home screen for iPhone.

This app can read the accelerometer and do phone dial or SMS dial for the same number based on the your setting for Portrait or Landscape Mode of iPhone.


Last edited by javacom; 12-24-2008 at 05:30 PM. Reason: Update the latest template 3.5.2 and most updated info for firmware 2.2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:48 AM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Default

Below is the old template version 2.1a for iPhone SDK beta 3
-----------------------------------------------------------------------------------------------

Assume, you have installed iPhone SDK Beta 3 and have a pwned iPhone and you want to port some 1.1.x applications to firmware 2.0 using the SDK development environment and the open toolchain header

You can do this

(1) Install iPhone SDK beta 3 from Apple

(2) Install the toolchain headers as per instructions from here
http://wikee.iphwn.org/howto:using_s...lchain_headers

But I have modified it for the Beta 3 SDK path as below
Code:
      $ sudo mkdir -p /Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/ 
      $ svn co http://iphone-dev.googlecode.com/svn/branches/include-1.2-sdk  
      $ cd include-1.2-sdk 
      $ ./configure --prefix=/Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/ 
      $ sudo sh install-headers.sh
(3) The Xcode template is updated to version 2.1 and includes 3 projects (a) Tool Chain Build (b) Cocoa Touch ToolChain (which includes a local UIKit.h header file for using the new UIKit classes in SDK (you can build UIShowCase (non-IB version)) (c) Window-Based Toolchain (which includes an interface builder (IB) file MainWindow.xib)



The installation instruction for version 2.1 is also revised as below by using the following commands in Mac Terminal


Code:
 
curl http://cocoatouchdev.com/javacom/ToolChainTemplate_v21a.zip  > ToolChainTemplate_v21a.zip 
unzip -o ToolChainTemplate_v21a.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"
MD5 (ToolChainTemplate_v21a.zip) = dac6bdf027c490cba32b7b278519e3b7

(4) This template supports "Build and Go" to "Device and Release" only, so you have to connect your iPhone to USB cable when "Build and Go"


(5) When using SDK framework to build toolchain iPhone App, you will discover that the header files are not updated and some methods will fail in the iPhone OS. But now you can update the header file using class-dump, see post 11 of this thread http://hackint0sh.org/forum/showpost...9&postcount=11

Additional Info
When using this template to create new project. The source code and header files should be added to the ./src folder of the new project and the support files like png and wav and xib (interface Builder) files should be put to the ./resources folder

There is a Makefile in the new project folder as well, so that you can run make to compile into .app folder and package it into zip file as well. You can then ssh/scp to the iPhone firmware 2.0 beta for testing.

There are some restrictions on the Application such as run as "mobile" user for the Apple SDK's build to device release method.

Both methods allow you to use the xcode organiser to debug the error message (such as NSLog() message) when running.


P.S.
This XCode Template was based on the project file and MakeFile from nesapp by NerveGas and modified and extended for the SDK API of iPhone OS 2.0

There are problems when porting the existing 1.1.x applications to firmware 2.0. Some of them are UIKit related, as Apple has changed the API in OS 2.0

The following posts showed some of the UIKit header and API problems and proposed solutions when porting from 1.1.x to 2.0 firmware. The development environment is pwned iPhone OS2.0 (5A240d) and iPhone SDK beta 3 with open toolchain header Xcode Template from this thread

Posts Index
Post 11 open toolchain header update
How to use class-dump for iPhone SDK to update open toolchain header

Post 9 HelloToolChain.app
setFont setColor methods in UITextLabel and UITextView (and the use of UIFont UIColor methods)

Post 10 HelloSlider.app
UISlider.h in SDK vs UISliderControl.h in open toolchain API

Post 12 HelloTouch.app
UIEvent.h, UITouch.h and touch events handling for open toolchain API

Post 13 HelloSensor.app
UIAccelerometer.h and the accelerometer method for open toolchain API
Post 21 another version using official SDK API & Template

Post 14 T4Two.app (a ported 2.0 firmware game)
Multitouch and property directives in UIView for open toolchain API

Post 15 UIShowCase
Add a new project template in the Xcode Template and use a local "UIKIt.h" header file to build the sample app UIShowCase (non-Interface Builder Version) from Apple

Post 19 tris.app
A ported 2.0 firmware game showing the Touch Event Handling in firmware 1.x methods vs. the firmware 2.0 methods

Post 22 SimpleTableView
A SDK sample app that use interface builder .xib file in Open toolchain, also add a UISearchBar in the UITableView

Firmware 2.0 Applications / Sources
nesapp from NerveGas (with souce code)
Erica Applications for iPhone 2.0 (no source code)
Erica Utilities for iPhone 2.0 (no source code)
iCountDown (ported to firmware 2.0, with source code and binary)
Embark (with binary), this application is very simple so I did not list out the source code, but you can simply get the method calls that it use by running this in Mac Terminal, this is also my shortcut method to study codes from other binary
Code:
strings Embark.app/Embark
T4Two.app (a ported 2.0 firmware game)
tris.app (a ported 2.0 firmware game)

Last edited by javacom; 11-13-2008 at 04:02 PM. Reason: Updated Knowledge Base Index
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 09:28 PM
termleech
Status: Offline
Junior Member
 
Join Date: Sep 2007
Posts: 2
Rep Power: 0
termleech is on a distinguished road
Default

I'm having some trouble with your template. I downloaded it and put it in the location you specified, but when I hit new project it doesn't show up as a project choice in XCode. I get an error that says the project file could not be parsed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #4 (permalink)  
Old 04-21-2008, 09:45 AM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Default

Please see updated installation instructions in Post #1 for version 2 of the Open Toolchain Xcode Template

Below is an old installation instruction for version 1

Quote:
You have to create the folder first
Code:
mkdir -p /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project\ Templates/iPhone\ Tool\ Chain
Then put the entire folder "Tool Chain Build" (after unzip) under this directory, the path should then become
Code:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project\ Templates/iPhone\ Tool\ Chain/Tool\ Chain\ Build/
when you ls, you should see
Code:
$ ls /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project\ Templates/iPhone\ Tool\ Chain/Tool\ Chain\ Build
APP.app		APP_Prefix.pch	src
APP.xcodeproj	Makefile	resources

Last edited by javacom; 05-24-2008 at 06:37 AM. Reason: Updated installation instruction for version 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 04-22-2008, 05:21 PM
termleech
Status: Offline
Junior Member
 
Join Date: Sep 2007
Posts: 2
Rep Power: 0
termleech is on a distinguished road
Default

Thanks a bunch. I obviously am an idiot and despite reading the first post like 10 times I missed the make this directory part. I was too anxious I guess. Everything is working now.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 04-24-2008, 02:22 PM
jashsayani's Avatar
jashsayani
Status: Offline
Respected Member
 
Join Date: Dec 2007
Posts: 952
Rep Power: 50
jashsayani is on a distinguished road
Default

Helpful post javacom...

THUMBS UP FOR YOU !
__________________
My iPhone
Firmware Roadmap
OTB 1.1.2 --> 1.1.4 --> 2.0 Beta --> BACK TO 1.1.4 --> 2.0 -> 2.0.1 -> 2.0.2 -> 2.1 -> 2.2 -> 3.0
SIM Unlock - thanks to NextSIM4

My Mac mini
2.0 GHz Dual core, 2GB RAM, 160 GB HDD, Leopard 10.5.8

My MacBook
Aluminium Unibody, 2.0 GHz Dual core, 4 GB RAM, 160 GB HDD, Leopard 10.5.8

My Blogs:
Jash's Blog: http://www.jashsayani.com
The iFone Blog: http://theifoneblog.blogspot.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #7 (permalink)  
Old 04-24-2008, 05:29 PM
cbecking
Status: Offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Rep Power: 0
cbecking is on a distinguished road
Default

any thoughts on this working with the newest SDK beta 4 from apple?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 04-25-2008, 05:20 AM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Default

There is a code signing enforcement with beta 4
and probably needs a hack on XCode and iPhone firmware as well. The ramdisk key also changed.

So it is better to stay with beta 3 atm. There are plenty of codes you can do with beta 3.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 05-07-2008, 06:23 AM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Default

There are problems using setFont setColor methods in UITextLabel and UITextView in the sdk compiler and open toolchain headers

Typically the code for setFont and setColor in firmware 1.1.x would be
Code:
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
UITextLabel* label;
[label setFont:[NSClassFromString(@"WebFontCache") createFontWithFamily:@"Helvetica" traits:0 size:17.]];
[label setColor:CGColorCreate(colorSpace, grayComponents)];
When porting these codes using the sdk compiler and the open toolchain headers to firmware 2.0, the iPhone OS 2.0 runtime will fail and show this error in the Xcode Organizer
Code:
[NSCFType CGColor]: unrecognized selector sent to instance
The reason is that the struct __GSFont and struct CGColor are not recognized in iPhone OS2.0 and it can be solved by including these in the code and used the new UIFont and UIColor methods in the SDK headers

Code:
typedef float CGFloat;
#import <UIKit/UIFont.h>
#import <UIKit/UIColor.h>


These two header files are in here and there are some new methods defined
Code:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks/UIKit.framework/Headers
There are two methods to convert these 1.1.x codes using setColor:CGColor to firmware 2.0 as below
Code:
firmware 1.1.x code
float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
[label setColor:CGColorCreate(colorSpace, grayComponents)];

firmware 2.0 code method 1 (using CGColor)
float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
[label setColor:[UIColor colorWithCGColor:CGColorCreate(colorSpace, grayComponents)]];

firmware 2.0 code method 2 (using Color Components)
[label setColor:[UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];

The following sample code demonstrates the use of UIFont and UIColor methods and will display the useless "Hello ToolChain" in iPhone OS 2.0 (pwned) if you use the Xcode template of this thread to build

There will be warning messages when build and just ignore them. To remove these warnings, the open toolchain headers should be amended.


Code:
/*
 HelloToolChain.app
 main.m
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

// include for the sdk compiler and open toolchain headers
#ifndef UIKIT_UIFont_UIColor_H
#define UIKIT_UIFont_UIColor_H
typedef float CGFloat;
#import <UIKit/UIFont.h>
#import <UIKit/UIColor.h>
#endif

@interface HelloToolChain : UIApplication
{
}
@end

@implementation HelloToolChain
- (void) applicationDidFinishLaunching: (NSNotification *)aNotification
{
	UIWindow *window = [[UIWindow alloc] initWithContentRect: [UIHardware fullScreenApplicationContentRect]];
	UITextLabel *label = [[UITextLabel alloc] initWithFrame: CGRectMake(0, 100, 320, 50)];
	[label setFont:[UIFont fontWithName:@"Marker Felt" size:50]];
	[label setCentersHorizontally: YES];
	[label setText:@"Hello ToolChain"];
	[label setBackgroundColor:[UIColor blackColor]];
	[label setColor:[UIColor whiteColor]];
	UIView *mainView = [[UIView alloc] initWithFrame: [UIHardware fullScreenApplicationContentRect]];
	[mainView addSubview: label];
	[mainView becomeFirstResponder];
	[window orderFront: self];
	[window makeKeyAndVisible];
	[window setContentView: mainView];
}
@end

int main(int argc, char *argv[]) {
	int returnCode;
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	returnCode = UIApplicationMain(argc, argv, [HelloToolChain class]);
	[pool release];
	return returnCode;
}

Last edited by javacom; 05-20-2008 at 07:20 AM. Reason: code amendment
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #10 (permalink)  
Old 05-09-2008, 01:26 AM
javacom's Avatar
javacom
Status: Offline
Developer
 
Join Date: Mar 2008
Posts: 304
Rep Power: 23
javacom will become famous soon enoughjavacom will become famous soon enough
Default UISliderControl of Open Toolchain Header

UISliderControl of Open Toolchain is not available in iPhone OS 2.0 runtime. It should be replaced by UISlider by adding the following header.

Code:
#import <UIKit/UISliderControl.h>
@interface UISlider : UISliderControl
@property float value;                                 // default 0.0. this value will be pinned to min/max
@property float minimumValue;                          // default 0.0. the current value may change if outside new min value
@property float maximumValue;                          // default 1.0. the current value may change if outside new max value

@property(retain) UIImage *minimumValueImage;          // default is nil. image that appears to left of control (e.g. speaker off)
@property(retain) UIImage *maximumValueImage;          // default is nil. image that appears to right of control (e.g. speaker max)
@end
The following code shows the use of UISlider in the SDK compiler with Open Tool Chain header environment.

Code:
/*
 HelloSlider.app
 main.m
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

// include for the sdk compiler and open toolchain header
#ifndef UIKIT_UIFont_UIColor_H
#define UIKIT_UIFont_UIColor_H
typedef float CGFloat;
#import <UIKit/UIFont.h>
#import <UIKit/UIColor.h>
#endif

#ifndef UIKIT_UISlider_H
#define UIKIT_UISlider_H
#import <UIKit/UISliderControl.h>
@interface UISlider : UISliderControl
@property float value;                                 // default 0.0. this value will be pinned to min/max
@property float minimumValue;                          // default 0.0. the current value may change if outside new min value
@property float maximumValue;                          // default 1.0. the current value may change if outside new max value

@property(retain) UIImage *minimumValueImage;          // default is nil. image that appears to left of control (e.g. speaker off)
@property(retain) UIImage *maximumValueImage;          // default is nil. image that appears to right of control (e.g. speaker max)
@end
#endif


@interface HelloSlider : UIApplication
{
	UIWindow *window;
	UIImageView *imgView;
	UIView *mainView;
	UISlider *slider;
}
- (void) handleSlider: (id)unused;
@end

@implementation HelloSlider

- (void) applicationDidFinishLaunching: (NSNotification *)aNotification
{
	CGRect rect = [UIHardware fullScreenApplicationContentRect];
	rect.origin.x = rect.origin.y = 0.0f;
	window = [[UIWindow alloc] initWithContentRect: rect];
	mainView = [[UIView alloc] initWithFrame:rect];
	imgView = [[UIImageView alloc] initWithImage:[UIImage imageAtPath:@"/System/Library/CoreServices/SpringBoard.app/Activate.png"]];
	[imgView setBackgroundColor:[UIColor clearColor]];
	[mainView addSubview: imgView ];
	[imgView setOrigin:CGPointMake(112,0)];

	slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 380, 280, 40)];
	[slider setShowValue:NO];
	[slider addTarget:self action:@selector(handleSlider:) forEvents:7]; // 7=drag, 2=up
	slider.minimumValue = 0.0;
	slider.maximumValue = 10.0;
	slider.value = 1.0;
	[mainView addSubview:slider];	


	[mainView becomeFirstResponder];
	[window setContentView: mainView];
	[window orderFront: self];
	[window makeKeyAndVisible];
}

- (void) handleSlider: (id)unused
{
	if (slider.value == 0.0) {
		[mainView setBackgroundColor:[UIColor whiteColor]];
	}
	else if (slider.value <= 1.0) {
		[mainView setBackgroundColor:[UIColor grayColor]];
	}
	else if (slider.value <= 2.0) {
		[mainView setBackgroundColor:[UIColor redColor]];
	}
	else if (slider.value <= 3.0) {
		[mainView setBackgroundColor:[UIColor greenColor]];
	}
	else if (slider.value <= 4.0) {
		[mainView setBackgroundColor:[UIColor blueColor]];
	}
	else if (slider.value <= 5.0) {
		[mainView setBackgroundColor:[UIColor cyanColor]];
	}
	else if (slider.value <= 6.0) {
		[mainView setBackgroundColor:[UIColor yellowColor]];
	}
	else if (slider.value <= 7.0) {
		[mainView setBackgroundColor:[UIColor magentaColor]];
	}
	else if (slider.value <= 8.0) {
		[mainView setBackgroundColor:[UIColor orangeColor]];
	}
	else if (slider.value <= 9.0) {
		[mainView setBackgroundColor:[UIColor purpleColor]];
	}
	else if (slider.value <= 10.0) {
		[mainView setBackgroundColor:[UIColor brownColor]];
	}
	else {
		[mainView setBackgroundColor:[UIColor whiteColor]];
	}
} 

@end

int main(int argc, char *argv[]) {
	int returnCode;
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	returnCode = UIApplicationMain(argc, argv, [HelloSlider class]);
	[pool release];
	return returnCode;
}

Last edited by javacom; 05-09-2008 at 03:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +2. The time now is 07:33 AM.



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 Ad Management by RedTyger
follow us on Twitter!

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105